From cd3135733af959931e228fa3e6ac8d622edb4d44 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 17 Jun 2020 10:57:31 +0200 Subject: platform: skip tc tests when the tc binary is not available 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. --- src/platform/tests/test-tc.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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); -- cgit v1.2.1