diff options
author | NĂcolas F. R. A. Prado <nfraprado@collabora.com> | 2024-02-01 01:02:41 +0300 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2024-02-21 01:53:08 +0300 |
commit | d90b7c705c5d9b5cb6b71b8aaa773c031084056c (patch) | |
tree | c0630739b23123d289a46bc3f3492310a0b1ab53 /tools | |
parent | 6934eea2690b3c8a95224f2d1dacc2f13d3bf4ce (diff) | |
download | linux-d90b7c705c5d9b5cb6b71b8aaa773c031084056c.tar.xz |
selftests: ktap_helpers: Add helper to pass/fail test based on exit code
Similar to the C counterpart, add a helper function that runs a command
and passes or fails the test based on the result.
Signed-off-by: NĂcolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/kselftest/ktap_helpers.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/testing/selftests/kselftest/ktap_helpers.sh b/tools/testing/selftests/kselftest/ktap_helpers.sh index ecc1413c22cd..29107924f5c2 100644 --- a/tools/testing/selftests/kselftest/ktap_helpers.sh +++ b/tools/testing/selftests/kselftest/ktap_helpers.sh @@ -76,6 +76,17 @@ ktap_test_fail() { KTAP_CNT_FAIL=$((KTAP_CNT_FAIL+1)) } +ktap_test_result() { + description="$1" + shift + + if $@; then + ktap_test_pass "$description" + else + ktap_test_fail "$description" + fi +} + ktap_print_totals() { echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0" } |