]> git.baikalelectronics.ru Git - kernel.git/commitdiff
selftests: mlxsw: bail_on_lldpad before installing the cleanup trap
authorPetr Machata <petrm@nvidia.com>
Wed, 4 May 2022 06:29:02 +0000 (09:29 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 4 May 2022 10:21:32 +0000 (11:21 +0100)
A number of mlxsw-specific QoS tests use manual QoS DCB management. As
such, they need to make sure lldpad is not running, because it would
override the configuration the test has applied using other tools. To that
end, these selftests invoke the bail_on_lldpad() helper, which terminates
the selftest if th lldpad is running.

Some of these tests however first install the bash exit trap, which invokes
a cleanup() at the test exit. If bail_on_lldpad() has terminated the script
even before the setup part was run, the cleanup part will be very confused.

Therefore make sure bail_on_lldpad() is invoked before the cleanup is
registered.

While there are still edge cases where the user terminates the script
before the setup was fully done, this takes care of a common situation
where the cleanup would be invoked in an inconsistent state.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/drivers/net/mlxsw/qos_headroom.sh
tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh
tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh
tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh

index f4493ef9cca1f33a98c9fa1aaaf3f1fe37b20be6..3569ff45f7d564a0d0434fb946f8edd5a795b904 100755 (executable)
@@ -371,9 +371,9 @@ test_tc_int_buf()
        tc qdisc delete dev $swp root
 }
 
-trap cleanup EXIT
-
 bail_on_lldpad
+
+trap cleanup EXIT
 setup_wait
 tests_run
 
index 5d5622fc27582e98b32e91fce63a74361827d56e..f9858e221996c17cd24776937769a7e77bef3e0b 100755 (executable)
@@ -393,9 +393,9 @@ test_qos_pfc()
        log_test "PFC"
 }
 
-trap cleanup EXIT
-
 bail_on_lldpad
+
+trap cleanup EXIT
 setup_prepare
 setup_wait
 tests_run
index 1e5ad320943664445f709284ebaf52501bb112d4..7a73057206cd090af039462be7c8e43bcc37a317 100755 (executable)
@@ -166,12 +166,11 @@ ecn_mirror_test()
        uninstall_qdisc
 }
 
-trap cleanup EXIT
+bail_on_lldpad
 
+trap cleanup EXIT
 setup_prepare
 setup_wait
-
-bail_on_lldpad
 tests_run
 
 exit $EXIT_STATUS
index d79a82f317d297c8d65aa69520e5f50623be8e0c..501d192529ac0fa2f44708a876214d34904c7840 100755 (executable)
@@ -73,12 +73,11 @@ red_mirror_test()
        uninstall_qdisc
 }
 
-trap cleanup EXIT
+bail_on_lldpad
 
+trap cleanup EXIT
 setup_prepare
 setup_wait
-
-bail_on_lldpad
 tests_run
 
 exit $EXIT_STATUS