selftests: forwarding: lib: Add check_err_fail()
authorPetr Machata <petrm@mellanox.com>
Sat, 30 Jun 2018 00:45:47 +0000 (02:45 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Jun 2018 13:06:15 +0000 (22:06 +0900)
In the scale testing scenarios, one usually has a condition that is
expected to either fail, or pass, depending on which side of the scale
is being tested.

To capture this logic, add a function check_err_fail(), which dispatches
either to check_err() or check_fail(), depending on the value of the
first argument, should_fail.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Yuval Mintz <yuvalm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/lib.sh

index 59272824ef37d93231bd066b8148b03f18709d44..5f4b7ed2c65a6aec8dbdd7b9c3398f068ab608f6 100644 (file)
@@ -156,6 +156,19 @@ check_fail()
        fi
 }
 
+check_err_fail()
+{
+       local should_fail=$1; shift
+       local err=$1; shift
+       local what=$1; shift
+
+       if ((should_fail)); then
+               check_fail $err "$what succeeded, but should have failed"
+       else
+               check_err $err "$what failed"
+       fi
+}
+
 log_test()
 {
        local test_name=$1