Merge branch 'w32-skips' into 'main'

Various win32 tests skip & fixes

See merge request GNOME/glib!2540
This commit is contained in:
Philip Withnall 2022-03-21 12:19:24 +00:00
commit 2e940e125f
8 changed files with 100 additions and 9 deletions

View File

@ -78,6 +78,11 @@ test_app_monitor (Fixture *fixture,
GAppInfoMonitor *monitor;
GMainLoop *loop;
#ifdef G_OS_WIN32
g_test_skip (".desktop monitor on win32");
return;
#endif
app_path = g_build_filename (fixture->applications_dir, "app.desktop", NULL);
/* FIXME: this shouldn't be required */

View File

@ -38,6 +38,10 @@ import taptestrunner
Result = collections.namedtuple("Result", ("info", "out", "err", "subs"))
def on_win32():
return sys.platform.find('win') != -1
class TestCodegen(unittest.TestCase):
"""Integration test for running gdbus-codegen.
@ -281,6 +285,7 @@ class TestCodegen(unittest.TestCase):
with self.assertRaises(subprocess.CalledProcessError):
self.runCodegen()
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_empty_interface_header(self):
"""Test generating a header with an empty interface file."""
result = self.runCodegenWithInterface("", "--output", "/dev/stdout", "--header")
@ -304,6 +309,7 @@ G_END_DECLS
result.out.strip(),
)
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_empty_interface_body(self):
"""Test generating a body with an empty interface file."""
result = self.runCodegenWithInterface("", "--output", "/dev/stdout", "--body")
@ -323,6 +329,7 @@ G_END_DECLS
result.out.strip(),
)
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_reproducible(self):
"""Test builds are reproducible regardless of file ordering."""
xml_contents1 = """
@ -422,6 +429,7 @@ G_END_DECLS
rst = f.readlines()
self.assertTrue(len(rst) != 0)
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_min_required_invalid(self):
"""Test running with an invalid --glib-min-required."""
with self.assertRaises(subprocess.CalledProcessError):
@ -434,6 +442,7 @@ G_END_DECLS
"hello mum",
)
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_min_required_too_low(self):
"""Test running with a --glib-min-required which is too low (and hence
probably a typo)."""
@ -442,6 +451,7 @@ G_END_DECLS
"", "--output", "/dev/stdout", "--body", "--glib-min-required", "2.6"
)
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_min_required_major_only(self):
"""Test running with a --glib-min-required which contains only a major version."""
result = self.runCodegenWithInterface(
@ -457,6 +467,7 @@ G_END_DECLS
self.assertEqual("", result.err)
self.assertNotEqual("", result.out.strip())
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_min_required_with_micro(self):
"""Test running with a --glib-min-required which contains a micro version."""
result = self.runCodegenWithInterface(
@ -465,6 +476,7 @@ G_END_DECLS
self.assertEqual("", result.err)
self.assertNotEqual("", result.out.strip())
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_max_allowed_too_low(self):
"""Test running with a --glib-max-allowed which is too low (and hence
probably a typo)."""
@ -473,6 +485,7 @@ G_END_DECLS
"", "--output", "/dev/stdout", "--body", "--glib-max-allowed", "2.6"
)
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_max_allowed_major_only(self):
"""Test running with a --glib-max-allowed which contains only a major version."""
result = self.runCodegenWithInterface(
@ -481,6 +494,7 @@ G_END_DECLS
self.assertEqual("", result.err)
self.assertNotEqual("", result.out.strip())
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_max_allowed_with_micro(self):
"""Test running with a --glib-max-allowed which contains a micro version."""
result = self.runCodegenWithInterface(
@ -489,6 +503,7 @@ G_END_DECLS
self.assertEqual("", result.err)
self.assertNotEqual("", result.out.strip())
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_max_allowed_unstable(self):
"""Test running with a --glib-max-allowed which is unstable. It should
be rounded up to the next stable version number, and hence should not
@ -506,6 +521,7 @@ G_END_DECLS
self.assertEqual("", result.err)
self.assertNotEqual("", result.out.strip())
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_glib_max_allowed_less_than_min_required(self):
"""Test running with a --glib-max-allowed which is less than
--glib-min-required."""
@ -521,6 +537,7 @@ G_END_DECLS
"2.64",
)
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_unix_fd_types_and_annotations(self):
"""Test an interface with `h` arguments, no annotation, and GLib < 2.64.
@ -579,6 +596,7 @@ G_END_DECLS
self.assertEqual("", result.err)
self.assertEqual(result.out.strip().count("GUnixFDList"), 18)
@unittest.skipIf(on_win32(), "requires /dev/stdout")
def test_call_flags_and_timeout_method_args(self):
"""Test that generated method call functions have @call_flags and
@timeout_msec args if and only if GLib >= 2.64.

View File

@ -171,6 +171,14 @@ else
}
endif
have_dbus_daemon = find_program('dbus-daemon', required : false).found()
if have_dbus_daemon
gio_tests += {
'debugcontroller' : {},
'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]},
}
endif
# Test programs buildable on UNIX only
if host_machine.system() != 'windows'
gio_tests += {
@ -244,8 +252,6 @@ if host_machine.system() != 'windows'
}
endif
# Test programs that need to bring up a session bus (requires dbus-daemon)
have_dbus_daemon = find_program('dbus-daemon', required : false).found()
if have_dbus_daemon
annotate_args = [
'--annotate', 'org.project.Bar', 'Key1', 'Value1',
@ -318,8 +324,6 @@ if host_machine.system() != 'windows'
'extra_sources' : extra_sources,
'suite' : ['slow'],
},
'debugcontroller' : {},
'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]},
'gdbus-auth' : {'extra_sources' : extra_sources},
'gdbus-bz627724' : {'extra_sources' : extra_sources},
'gdbus-close-pending' : {'extra_sources' : extra_sources},

View File

@ -1358,6 +1358,13 @@ test_unix_from_fd (void)
GSocket *s;
fd = socket (AF_UNIX, SOCK_STREAM, 0);
#ifdef G_OS_WIN32
if (fd == -1)
{
g_test_skip ("AF_UNIX not supported on this Windows system.");
return;
}
#endif
g_assert_cmpint (fd, !=, -1);
bind_win32_unixfd (fd);
@ -1380,6 +1387,13 @@ test_unix_connection (void)
GSocketConnection *c;
fd = socket (AF_UNIX, SOCK_STREAM, 0);
#ifdef G_OS_WIN32
if (fd == -1)
{
g_test_skip ("AF_UNIX not supported on this Windows system.");
return;
}
#endif
g_assert_cmpint (fd, !=, -1);
bind_win32_unixfd (fd);
@ -1518,6 +1532,14 @@ test_source_postmortem (void)
gboolean callback_visited = FALSE;
socket = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT, &error);
#ifdef G_OS_WIN32
if (error)
{
g_test_skip_printf ("AF_UNIX not supported on this Windows system: %s", error->message);
g_clear_error (&error);
return;
}
#endif
g_assert_no_error (error);
context = g_main_context_new ();
@ -2225,6 +2247,11 @@ test_credentials_unix_socketpair (void)
#ifdef G_OS_WIN32
status = _g_win32_socketpair (PF_UNIX, SOCK_STREAM, 0, fds);
if (status != 0)
{
g_test_skip ("AF_UNIX not supported on this Windows system.");
return;
}
#else
status = socketpair (PF_UNIX, SOCK_STREAM, 0, fds);
#endif

View File

@ -4,6 +4,17 @@
#include <stdlib.h>
#include <gio/gio.h>
static gboolean
skip_win32 (void)
{
#ifdef G_OS_WIN32
g_test_skip ("FIXME, test is broken on win32");
return TRUE;
#else
return FALSE;
#endif
}
/* These tests were written for the inotify implementation.
* Other implementations may require slight adjustments in
* the tests, e.g. the length of timeouts
@ -361,6 +372,9 @@ test_atomic_replace (Fixture *fixture,
GError *error = NULL;
TestData data;
if (skip_win32 ())
return;
data.step = 0;
data.events = NULL;
@ -466,6 +480,9 @@ test_file_changes (Fixture *fixture,
GError *error = NULL;
TestData data;
if (skip_win32 ())
return;
data.step = 0;
data.events = NULL;
@ -583,6 +600,9 @@ test_dir_monitor (Fixture *fixture,
GError *error = NULL;
TestData data;
if (skip_win32 ())
return;
data.step = 0;
data.events = NULL;
@ -680,6 +700,9 @@ test_dir_non_existent (Fixture *fixture,
TestData data;
GError *error = NULL;
if (skip_win32 ())
return;
data.step = 0;
data.events = NULL;
@ -789,6 +812,9 @@ test_cross_dir_moves (Fixture *fixture,
GError *error = NULL;
TestData data[2];
if (skip_win32 ())
return;
data[0].step = 0;
data[0].events = NULL;
@ -960,6 +986,9 @@ test_file_hard_links (Fixture *fixture,
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=755721");
if (skip_win32 ())
return;
#ifdef HAVE_LINK
g_test_message ("Running with hard link tests");
#else /* if !HAVE_LINK */

View File

@ -1854,14 +1854,17 @@ test_nfds (void)
/* Now actually iterate the loop; the fd should be readable and
* writable, so source1 and source3 should be triggered, but *not*
* source2, since it's lower priority than them. (Though on
* G_OS_WIN32, source3 doesn't get triggered, probably because of
* giowin32 weirdness...)
* source2, since it's lower priority than them.
*/
g_main_context_iteration (ctx, FALSE);
g_assert_true (source1_ran);
/* FIXME:
* On win32, giowin32.c uses blocking threads for read/write on channels. They
* may not have yet triggered an event after one loop iteration. Hence, the
* following asserts are racy and disabled.
*/
#ifndef G_OS_WIN32
g_assert_true (source1_ran);
g_assert_true (source3_ran);
#endif

View File

@ -154,6 +154,11 @@ test_private3 (void)
* functions (instead of TLS) as proposed in
* https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1655
*/
if (!private3_freed)
{
g_test_skip ("FIXME: GPrivate with native win32 thread");
return;
}
}
#else
{

View File

@ -56,7 +56,7 @@ test_timer_basic (void)
elapsed = g_timer_elapsed (timer, &micros);
g_assert_cmpfloat (elapsed, <, 1.0);
g_assert_cmpuint (micros, ==, ((guint64)(elapsed * 1e6)) % 1000000);
g_assert_cmpfloat_with_epsilon (elapsed, micros / 1e6, 0.001);
g_timer_destroy (timer);
}