From f7e3cc0b7134a28d76d428e28671ae2de8913f49 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 2 Dec 2019 17:03:34 +0100 Subject: [PATCH] platform/tests: skip team test when we fail to create team link This is necessary on Travis/Ubuntu 16.04, otherwise the test fails with # NetworkManager-MESSAGE: [1575301791.7600] platform-linux: do-add-link[nm-test-device/team]: failure 95 (Operation not supported) Aborted (core dumped) # test:ERROR:../src/platform/tests/test-link.c:353:test_software: assertion failed: (software_add (link_type, DEVICE_NAME)) ERROR: src/platform/tests/test-link-linux - too few tests run (expected 76, got 6) --- src/platform/tests/test-link.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index 421a77b905..37e1cde516 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -463,9 +463,9 @@ _system (const char *cmd) static void test_bond (void) { - if (nmtstp_is_root_test () && - !g_file_test ("/proc/1/net/bonding", G_FILE_TEST_IS_DIR) && - _system("modprobe --show bonding") != 0) { + if ( nmtstp_is_root_test () + && !g_file_test ("/proc/1/net/bonding", G_FILE_TEST_IS_DIR) + && _system("modprobe --show bonding") != 0) { g_test_skip ("Skipping test for bonding: bonding module not available"); return; } @@ -476,6 +476,20 @@ test_bond (void) static void test_team (void) { + int r; + + if (nmtstp_is_root_test ()) { + r = nm_platform_link_team_add (NM_PLATFORM_GET, "nm-team-check", NULL); + + if (r < 0) { + g_assert_cmpint (r, ==, -EOPNOTSUPP); + g_test_skip ("Skipping test for teaming: team module not functioning"); + return; + } + + nmtstp_link_delete (NM_PLATFORM_GET, -1, -1, "nm-team-check", FALSE); + } + test_software (NM_LINK_TYPE_TEAM, "team"); }