diff options
author | Thomas Haller <thaller@redhat.com> | 2018-10-03 00:59:17 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-10-04 10:58:50 +0200 |
commit | eea1886d935232a2f355e1a32d75aae2612e0110 (patch) | |
tree | fe0436fe37c96cb8dd3593d0b56ee33af01dd7e6 | |
parent | 6a616c3c7e570419e30504e2ec281719ea215d2e (diff) |
acd/tests: skip NAcd tests under valgrind
Under valgrind, we cannot create an NAcd instance.
--10916-- WARNING: unhandled amd64-linux syscall: 321
--10916-- You may be able to write your own handler.
--10916-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--10916-- Nevertheless we consider this a bug. Please report
--10916-- it at http://valgrind.org/support/bug_reports.html.
This limitation already poses a problem, because running NetworkManager
under valgrind might fail. However, for tests it doesn't matter and we
can just skip them.
-rw-r--r-- | src/devices/tests/test-acd.c | 48 | ||||
-rwxr-xr-x | tools/run-nm-test.sh | 7 |
2 files changed, 53 insertions, 2 deletions
diff --git a/src/devices/tests/test-acd.c b/src/devices/tests/test-acd.c index 6f4ba8d8f..28910338e 100644 --- a/src/devices/tests/test-acd.c +++ b/src/devices/tests/test-acd.c @@ -20,6 +20,8 @@ #include "nm-default.h" +#include "n-acd/src/n-acd.h" + #include "devices/nm-acd-manager.h" #include "platform/tests/test-common.h" @@ -31,6 +33,46 @@ #define ADDR3 0x03030303 #define ADDR4 0x04040404 +/*****************************************************************************/ + +static gboolean +_skip_acd_test_check (void) +{ + NAcd *acd; + NAcdConfig *config; + const guint8 hwaddr[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; + int r; + static int skip = -1; + + if (skip == -1) { + r = n_acd_config_new (&config); + g_assert (r == 0); + + n_acd_config_set_ifindex (config, 1); + n_acd_config_set_transport (config, N_ACD_TRANSPORT_ETHERNET); + n_acd_config_set_mac (config, hwaddr, sizeof (hwaddr)); + + r = n_acd_new (&acd, config); + n_acd_config_free (config); + if (r == 0) + n_acd_unref (acd); + + skip = (r != 0); + } + return skip; +} + +#define _skip_acd_test() \ + ({ \ + gboolean _skip = _skip_acd_test_check (); \ + \ + if (_skip) \ + g_test_skip ("Cannot create NAcd. Running under valgind?"); \ + _skip; \ + }) + +/*****************************************************************************/ + typedef struct { int ifindex0; int ifindex1; @@ -79,6 +121,9 @@ test_acd_common (test_fixture *fixture, TestInfo *info) .user_data_destroy = (GDestroyNotify) g_main_loop_unref, }; + if (_skip_acd_test ()) + return; + /* first, try with a short waittime. We hope that this is long enough * to successfully complete the test. Only if that's not the case, we * assume the computer is currently busy (high load) and we retry with @@ -156,6 +201,9 @@ test_acd_announce (test_fixture *fixture, gconstpointer user_data) NMAcdManager *manager; GMainLoop *loop; + if (_skip_acd_test ()) + return; + manager = nm_acd_manager_new (fixture->ifindex0, fixture->hwaddr0, fixture->hwaddr0_len, diff --git a/tools/run-nm-test.sh b/tools/run-nm-test.sh index 6b96a139d..6e7d02c84 100755 --- a/tools/run-nm-test.sh +++ b/tools/run-nm-test.sh @@ -294,8 +294,11 @@ fi if [ $HAS_ERRORS -eq 0 ]; then # valgrind doesn't support setns syscall and spams the logfile. # hack around it... - if [ "$TEST_NAME" = 'test-link-linux' -a -z "$(sed -e '/^--[0-9]\+-- WARNING: unhandled .* syscall: /,/^--[0-9]\+-- it at http.*\.$/d' "$LOGFILE")" ]; then - HAS_ERRORS=1 + if [ "$TEST_NAME" = 'test-link-linux' -o \ + "$TEST_NAME" = 'test-acd' ]; then + if [ -z "$(sed -e '/^--[0-9]\+-- WARNING: unhandled .* syscall: /,/^--[0-9]\+-- it at http.*\.$/d' "$LOGFILE")" ]; then + HAS_ERRORS=1 + fi fi fi |