From 72cafb8ca35923d3c1f7289ed1386fbf6b23a7ff Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 20 Oct 2014 13:24:44 +0200 Subject: [PATCH 1/7] build: Don't conditionally omit files from distribution --- callouts/tests/Makefile.am | 4 ++-- src/settings/plugins/ibft/tests/Makefile.am | 4 ++-- src/settings/plugins/ifnet/tests/Makefile.am | 4 ++-- src/settings/plugins/ifupdown/tests/Makefile.am | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/callouts/tests/Makefile.am b/callouts/tests/Makefile.am index db73ef9372..2e53c5fc16 100644 --- a/callouts/tests/Makefile.am +++ b/callouts/tests/Makefile.am @@ -29,10 +29,10 @@ test_dispatcher_envp_LDADD = \ TESTS = test-dispatcher-envp +endif + EXTRA_DIST= \ dispatcher-old-down \ dispatcher-old-up \ dispatcher-old-vpn-down \ dispatcher-old-vpn-up - -endif diff --git a/src/settings/plugins/ibft/tests/Makefile.am b/src/settings/plugins/ibft/tests/Makefile.am index 62011759fa..927484f1c9 100644 --- a/src/settings/plugins/ibft/tests/Makefile.am +++ b/src/settings/plugins/ibft/tests/Makefile.am @@ -35,6 +35,8 @@ test_ibft_LDADD = \ TESTS = test-ibft +endif + EXTRA_DIST = \ iscsiadm-test-dhcp \ iscsiadm-test-static \ @@ -46,5 +48,3 @@ EXTRA_DIST = \ iscsiadm-test-bad-record \ iscsiadm-test-vlan -endif - diff --git a/src/settings/plugins/ifnet/tests/Makefile.am b/src/settings/plugins/ifnet/tests/Makefile.am index 90d7243020..25001d1363 100644 --- a/src/settings/plugins/ifnet/tests/Makefile.am +++ b/src/settings/plugins/ifnet/tests/Makefile.am @@ -36,6 +36,8 @@ check_ifnet_LDADD = $(top_builddir)/src/libNetworkManager.la check-local: check_ifnet $(abs_builddir)/check_ifnet $(abs_srcdir) $(abs_builddir) +endif + EXTRA_DIST = \ hostname \ net \ @@ -43,5 +45,3 @@ EXTRA_DIST = \ nm-system-settings.conf \ wpa_supplicant.conf \ test_ca_cert.pem - -endif diff --git a/src/settings/plugins/ifupdown/tests/Makefile.am b/src/settings/plugins/ifupdown/tests/Makefile.am index 14a58f87e5..24cdd95504 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.am +++ b/src/settings/plugins/ifupdown/tests/Makefile.am @@ -25,10 +25,10 @@ test_ifupdown_LDADD = \ TESTS = test-ifupdown +endif + EXTRA_DIST = \ test1 test2 test3 test4 test5 test6 test7 test8 test9 test11 test12 \ test13 test14 test15 test16 test17-wired-static-verify-ip4 \ test18-wired-static-verify-ip6 test19-wired-static-verify-ip4-plen \ test20-source-stanza test20-source-stanza.eth0 test20-source-stanza.eth1 - -endif From e9bfd0e29c164b79205c23617b199573b78abd5b Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 20 Oct 2014 18:24:26 +0200 Subject: [PATCH 2/7] tests: Don't run session-long dbus daemons for tests They require a tty or X11 displays, thus are not suitable for headless runs (such as in mock). Furthermore, they die with the tty or X11 session, which is somehow late -- a lot of them may accumulate. Let's kill them right away. --- libnm-glib/tests/libnm-glib-test-launch.sh | 8 +++++--- libnm/tests/libnm-test-launch.sh | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libnm-glib/tests/libnm-glib-test-launch.sh b/libnm-glib/tests/libnm-glib-test-launch.sh index 1db656ad06..42d9fbe26d 100755 --- a/libnm-glib/tests/libnm-glib-test-launch.sh +++ b/libnm-glib/tests/libnm-glib-test-launch.sh @@ -1,7 +1,9 @@ #!/bin/sh +# Spawn DBus if there's none if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then - exec dbus-launch --exit-with-session "$@" -else - exec "$@" + eval `dbus-launch --sh-syntax` + trap "kill $DBUS_SESSION_BUS_PID" EXIT fi + +"$@" diff --git a/libnm/tests/libnm-test-launch.sh b/libnm/tests/libnm-test-launch.sh index 1db656ad06..42d9fbe26d 100755 --- a/libnm/tests/libnm-test-launch.sh +++ b/libnm/tests/libnm-test-launch.sh @@ -1,7 +1,9 @@ #!/bin/sh +# Spawn DBus if there's none if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then - exec dbus-launch --exit-with-session "$@" -else - exec "$@" + eval `dbus-launch --sh-syntax` + trap "kill $DBUS_SESSION_BUS_PID" EXIT fi + +"$@" From b54030de222ff5d1cf5c6643cda38a8d1552dabf Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 23 Oct 2014 17:40:40 +0200 Subject: [PATCH 3/7] core: Fall back to CLOCK_MONOTONIC if CLOCK_BOOTTIME unsupported It was added fairly recently (2.6.39), this breaks run (and test run in mock) on RHEL-6 with 2.6.32. --- src/NetworkManagerUtils.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 66da861daf..1d80c3a58b 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -1740,15 +1740,36 @@ static gint64 monotonic_timestamp_offset_sec; static void monotonic_timestamp_get (struct timespec *tp) { - static gboolean initialized = FALSE; - int err; + static int clock_mode = 0; + gboolean first_time = FALSE; + int err = 0; - err = clock_gettime (CLOCK_BOOTTIME, tp); + switch (clock_mode) { + case 0: + /* the clock is not yet initialized (first run) */ + err = clock_gettime (CLOCK_BOOTTIME, tp); + if (err == -1 && errno == EINVAL) { + clock_mode = 2; + err = clock_gettime (CLOCK_MONOTONIC, tp); + } else + clock_mode = 1; + first_time = TRUE; + break; + case 1: + /* default, return CLOCK_BOOTTIME */ + err = clock_gettime (CLOCK_BOOTTIME, tp); + break; + case 2: + /* fallback, return CLOCK_MONOTONIC. Kernels prior to 2.6.39 + * don't support CLOCK_BOOTTIME. */ + err = clock_gettime (CLOCK_MONOTONIC, tp); + break; + } g_assert (err == 0); (void)err; g_assert (tp->tv_nsec >= 0 && tp->tv_nsec < NM_UTILS_NS_PER_SECOND); - if (G_LIKELY (initialized)) + if (G_LIKELY (!first_time)) return; /* Calculate an offset for the time stamp. @@ -1765,7 +1786,6 @@ monotonic_timestamp_get (struct timespec *tp) * wraps (~68 years). **/ monotonic_timestamp_offset_sec = (- ((gint64) tp->tv_sec)) + 1; - initialized = TRUE; if (nm_logging_enabled (LOGL_DEBUG, LOGD_CORE)) { time_t now = time (NULL); @@ -1774,8 +1794,9 @@ monotonic_timestamp_get (struct timespec *tp) strftime (s, sizeof (s), "%Y-%m-%d %H:%M:%S", localtime_r (&now, &tm)); nm_log_dbg (LOGD_CORE, "monotonic timestamp started counting 1.%09ld seconds ago with " - "an offset of %lld.0 seconds to CLOCK_BOOTTIME (local time is %s)", - tp->tv_nsec, (long long) -monotonic_timestamp_offset_sec, s); + "an offset of %lld.0 seconds to %s (local time is %s)", + tp->tv_nsec, (long long) -monotonic_timestamp_offset_sec, + clock_mode == 1 ? "CLOCK_BOOTTIME" : "CLOCK_MONOTONIC", s); } } From 4496b69e47eac8e4748fc3e452571b61498916f1 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 23 Oct 2014 16:51:41 +0200 Subject: [PATCH 4/7] libnm: Ignore NoReply errors when NM has vanished from the bus This fixes the /libnm/client-nm-running test failure when a race condition is hit: test-nm-client:10350): libnm-WARNING **: updated_properties: error reading NMRemoteSettings properties: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message did not receive a reply (timeout by message bus) What actually happens is that nm_running_changed_cb() calls GetAll() for a NMRemoteSettings object when NM appears on the bus. If it disappears shortly afterwards, another nm_running_changed_cb() is called which suppresses further object updates, but the original GetAll() might not have finished yet and DBus will generate a NoReply() response for it. We ought to ignore it. --- libnm/nm-object.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libnm/nm-object.c b/libnm/nm-object.c index 0e82861fc4..3a95252ead 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -1632,11 +1632,17 @@ _nm_object_reload_properties_async (NMObject *object, GAsyncReadyCallback callba gboolean _nm_object_reload_properties_finish (NMObject *object, GAsyncResult *result, GError **error) { + NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object); GSimpleAsyncResult *simple; g_return_val_if_fail (NM_IS_OBJECT (object), FALSE); g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (object), _nm_object_reload_properties_async), FALSE); + /* NM might have disappeared meanwhile. That would cause a NoReply error to be emitted, + * but we don't care if property updates were disabled. */ + if (priv->suppress_property_updates) + return TRUE; + simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) return FALSE; From afbc2571a13d043854708391b74e3be5f3035d1c Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 29 Oct 2014 10:18:31 +0100 Subject: [PATCH 5/7] libnm/tests: Properly wait for devices in /libnm/activate-virtual Ignore the signal if we're signalled before the second device is available and wait for another one. --- libnm/tests/test-nm-client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 26ffbec4ac..85d8c7d28f 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -888,6 +888,8 @@ client_devices_changed_cb (GObject *client, devices = nm_client_get_devices (NM_CLIENT (client)); g_assert (devices != NULL); + if (devices->len < 2) + return; g_assert_cmpint (devices->len, ==, 2); if (NM_IS_DEVICE_VLAN (devices->pdata[0])) From 7ad8b8a358a2d3297b6682e739023cd85c4bad93 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 23 Oct 2014 17:29:57 +0200 Subject: [PATCH 6/7] tests: Fix /general/nm_utils_kill_child race /general/nm_utils_kill_child: ** GLib:ERROR:test-general-with-expect.c:105:test_nm_utils_kill_child_sync_do: Did not see expected message NetworkManager-DEBUG: *kill child process 'test-s-1-1' (*): waiting up to 500 milliseconds for process to terminate normally after sending SIGTERM (15)... Aborted The first test case assumes the child does not go away immediately after being delivered a TERM signal. Add some delay to its teardown code path, so that NM will set up the timeout the test expects. --- src/tests/test-general-with-expect.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index f9dedbfef9..4d574ed74f 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -188,6 +188,7 @@ test_nm_utils_kill_child (void) char *argv1[] = { "sh", "-c", + "trap \"sleep 0.3; exit 10\" EXIT; " "sleep 100000; exit $? #" TEST_TOKEN, NULL, }; From 9db55be9a1ba5b680867611889c5585616f95f38 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 23 Oct 2014 19:27:35 +0200 Subject: [PATCH 7/7] contrib/rpm: Run make check --- contrib/fedora/rpm/NetworkManager.spec | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index 4ee0a3eb4d..d208b9101f 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -166,6 +166,9 @@ BuildRequires: ModemManager-glib-devel >= 1.0 %if 0%{?with_nmtui} BuildRequires: newt-devel %endif +BuildRequires: /usr/bin/dbus-launch +BuildRequires: pygobject3-base +BuildRequires: dbus-python %description @@ -468,6 +471,10 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/conf.d %{__rm} -rf $RPM_BUILD_ROOT +%check +make check + + %post %systemd_post NetworkManager.service NetworkManager-wait-online.service NetworkManager-dispatcher.service