diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2020-06-17 10:57:31 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2020-06-17 11:02:33 +0200 |
commit | cd3135733af959931e228fa3e6ac8d622edb4d44 (patch) | |
tree | 26b4a97eb518899608bbbe146b6ac582ad7effd0 | |
parent | 3e2135788830396e7142a8201b809074e42889d1 (diff) | |
download | NetworkManager-bg/tc-tests-skip.tar.gz |
platform: skip tc tests when the tc binary is not availablebg/tc-tests-skip
NetworkManager doesn't require the presence of the 'tc' binary. It is
however required for unit tests and the Fedora spec file has a build
dependency on it.
Instead of strictly requiring it, skip tests if the tool is not
available.
-rw-r--r-- | src/platform/tests/test-tc.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/platform/tests/test-tc.c b/src/platform/tests/test-tc.c index 0c90fcfab6..702af8e25d 100644 --- a/src/platform/tests/test-tc.c +++ b/src/platform/tests/test-tc.c @@ -37,6 +37,21 @@ qdiscs_lookup (int ifindex) NULL, NULL); } +static gboolean +skip_tc_test (void) +{ + static int tc_found = -1; + + if (tc_found == -1) + tc_found = (nmtstp_run_command ("tc >/dev/null 2>&1") == 0); + + if (!tc_found) { + g_test_skip ("The 'tc' binary is not available"); + return TRUE; + } + return FALSE; +} + static void test_qdisc1 (void) { @@ -46,6 +61,9 @@ test_qdisc1 (void) NMPObject *obj; NMPlatformQdisc *qdisc; + if (skip_tc_test ()) + return; + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint (ifindex, >, 0); @@ -83,6 +101,9 @@ test_qdisc_fq_codel (void) NMPObject *obj; NMPlatformQdisc *qdisc; + if (skip_tc_test ()) + return; + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint (ifindex, >, 0); @@ -122,6 +143,9 @@ test_qdisc_sfq (void) NMPObject *obj; NMPlatformQdisc *qdisc; + if (skip_tc_test ()) + return; + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint (ifindex, >, 0); @@ -161,6 +185,9 @@ test_qdisc_tbf (void) NMPObject *obj; NMPlatformQdisc *qdisc; + if (skip_tc_test ()) + return; + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint (ifindex, >, 0); |