diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c index fd0c64b55..59411c3a8 100644 --- a/gio/tests/g-file-info.c +++ b/gio/tests/g-file-info.c @@ -654,7 +654,11 @@ test_internal_enhanced_stdio (void) g_assert_cmpuint (alsize_ps, <, 0x40000000); g_assert_cmpuint (size_ps, >, G_GUINT64_CONSTANT (0xFFFFFFFF)); g_assert_cmpuint (statbuf_ps.st_size, >, 0); +#if defined(_WIN64) + g_assert_cmpuint (statbuf_ps.st_size, ==, G_GUINT64_CONSTANT (0x10000000f)); +#else g_assert_cmpuint (statbuf_ps.st_size, <=, 0xFFFFFFFF); +#endif g_object_unref (fi_ps); g_object_unref (gf_ps); diff --git a/gio/tests/socket.c b/gio/tests/socket.c index a8bab16df..4dae36b17 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -2241,7 +2241,7 @@ test_credentials_unix_socketpair (void) { gint fds[2]; gint status; - GSocket *sock; + GSocket *sock[2]; GError *error = NULL; GCredentials *creds; @@ -2257,9 +2257,12 @@ test_credentials_unix_socketpair (void) #endif g_assert_cmpint (status, ==, 0); - sock = g_socket_new_from_fd (fds[0], &error); + sock[0] = g_socket_new_from_fd (fds[0], &error); + g_assert_no_error (error); + sock[1] = g_socket_new_from_fd (fds[1], &error); + g_assert_no_error (error); - creds = g_socket_get_credentials (sock, &error); + creds = g_socket_get_credentials (sock[0], &error); if (creds != NULL) { gchar *str = g_credentials_to_string (creds); @@ -2274,8 +2277,8 @@ test_credentials_unix_socketpair (void) g_clear_error (&error); } - g_object_unref (sock); - g_close (fds[1], NULL); + g_object_unref (sock[0]); + g_object_unref (sock[1]); } #endif diff --git a/glib/gdate.c b/glib/gdate.c index 73a732df3..68c8689ef 100644 --- a/glib/gdate.c +++ b/glib/gdate.c @@ -2556,9 +2556,7 @@ win32_strftime_helper (const GDate *d, break; case 'Z': n = GetTimeZoneInformation (&tzinfo); - if (n == TIME_ZONE_ID_UNKNOWN) - ; - else if (n == TIME_ZONE_ID_STANDARD) + if (n == TIME_ZONE_ID_UNKNOWN || n == TIME_ZONE_ID_STANDARD) g_array_append_vals (result, tzinfo.StandardName, wcslen (tzinfo.StandardName)); else if (n == TIME_ZONE_ID_DAYLIGHT) g_array_append_vals (result, tzinfo.DaylightName, wcslen (tzinfo.DaylightName)); diff --git a/glib/tests/date.c b/glib/tests/date.c index 8903b8f0c..e382295c4 100644 --- a/glib/tests/date.c +++ b/glib/tests/date.c @@ -826,6 +826,8 @@ test_two_digit_years (void) GDate *d; gchar buf[101]; gchar *old_locale; + gboolean use_alternative_format = FALSE; + #ifdef G_OS_WIN32 LCID old_lcid; #endif @@ -848,6 +850,25 @@ test_two_digit_years (void) g_date_strftime (buf, sizeof (buf), "%D", d); g_assert_cmpstr (buf, ==, "10/10/76"); g_date_set_parse (d, buf); + +#ifdef G_OS_WIN32 + /* + * It depends on the locale setting whether the dd/mm/yy + * format is allowed for g_date_set_parse() on Windows, which + * corresponds to whether there is an d/M/YY or d/M/YYYY (or so) + * option in the "Date and Time Format" setting for the selected + * locale in the Control Panel settings. If g_date_set_parse() + * renders the GDate invalid with the dd/mm/yy format, use an + * alternative format (yy/mm/dd) for g_date_set_parse() for the + * 2-digit year tests. + */ + if (!g_date_valid (d)) + use_alternative_format = TRUE; +#endif + + if (use_alternative_format) + g_date_set_parse (d, "76/10/10"); + g_assert_cmpint (g_date_get_month (d), ==, 10); g_assert_cmpint (g_date_get_day (d), ==, 10); g_assert_true ((g_date_get_year (d) == 1976) || @@ -857,7 +878,7 @@ test_two_digit_years (void) g_date_set_dmy (d, 10, 10, 29); g_date_strftime (buf, sizeof (buf), "%D", d); g_assert_cmpstr (buf, ==, "10/10/29"); - g_date_set_parse (d, buf); + g_date_set_parse (d, use_alternative_format ? "29/10/10" : buf); g_assert_cmpint (g_date_get_month (d), ==, 10); g_assert_cmpint (g_date_get_day (d), ==, 10); g_assert_true ((g_date_get_year (d) == 2029) || diff --git a/glib/tests/protocol.c b/glib/tests/protocol.c index 27ebd99be..b03aaf97b 100644 --- a/glib/tests/protocol.c +++ b/glib/tests/protocol.c @@ -100,7 +100,10 @@ test_message_cb1 (GIOChannel * channel, g_test_log_buffer_push (user_data, read_bytes, buf); } - g_assert_cmpuint (status, ==, G_IO_STATUS_AGAIN); + if (status == G_IO_STATUS_EOF) + return FALSE; + else + g_assert_cmpuint (status, ==, G_IO_STATUS_AGAIN); return TRUE; } @@ -133,7 +136,6 @@ test_message (void) GMainLoop * loop; GError * error = NULL; gulong child_source; - gulong io_source; GPid pid = 0; int pipes[2]; int passed = 0; @@ -159,6 +161,7 @@ test_message (void) g_error ("error spawning the test: %s", error->message); } + close (pipes[1]); tlb = g_test_log_buffer_new (); loop = g_main_loop_new (NULL, FALSE); @@ -181,7 +184,7 @@ test_message (void) g_assert (g_io_channel_get_encoding (channel) == NULL); g_assert (!g_io_channel_get_buffered (channel)); - io_source = g_io_add_watch (channel, G_IO_IN, test_message_cb1, tlb); + g_io_add_watch (channel, G_IO_IN, test_message_cb1, tlb); child_source = g_child_watch_add (pid, test_message_cb2, loop); g_main_loop_run (loop); @@ -191,7 +194,6 @@ test_message (void) g_test_expect_message ("GLib", G_LOG_LEVEL_CRITICAL, "Source ID*"); g_assert (!g_source_remove (child_source)); g_test_assert_expected_messages (); - g_assert (g_source_remove (io_source)); g_io_channel_unref (channel); for (msg = g_test_log_buffer_pop (tlb); @@ -264,7 +266,6 @@ test_error (void) GMainLoop * loop; GError * error = NULL; gulong child_source; - gulong io_source; GPid pid = 0; int pipes[2]; @@ -286,6 +287,7 @@ test_error (void) g_error ("error spawning the test: %s", error->message); } + close (pipes[1]); tlb = g_test_log_buffer_new (); loop = g_main_loop_new (NULL, FALSE); @@ -299,7 +301,7 @@ test_error (void) g_io_channel_set_buffered (channel, FALSE); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); - io_source = g_io_add_watch (channel, G_IO_IN, test_message_cb1, tlb); + g_io_add_watch (channel, G_IO_IN, test_message_cb1, tlb); child_source = g_child_watch_add (pid, test_message_cb2, loop); g_main_loop_run (loop); @@ -309,7 +311,6 @@ test_error (void) g_test_expect_message ("GLib", G_LOG_LEVEL_CRITICAL, "Source ID*"); g_assert (!g_source_remove (child_source)); g_test_assert_expected_messages (); - g_assert (g_source_remove (io_source)); g_io_channel_unref (channel); for (msg = g_test_log_buffer_pop (tlb);