From: Petr Machata Date: Sat, 30 Jun 2018 00:45:47 +0000 (+0200) Subject: selftests: forwarding: lib: Add check_err_fail() X-Git-Tag: android-x86-8.1-r1~477^2~494^2~11 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=96fa91d281229390b75a004d49582400b5f93cb1;p=android-x86%2Fkernel.git selftests: forwarding: lib: Add check_err_fail() 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 Reviewed-by: Yuval Mintz Signed-off-by: David S. Miller --- diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 59272824ef37..5f4b7ed2c65a 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -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