Skip to content

Commit d90b7c7

Browse files
nfrapradoshuahkh
authored andcommitted
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>
1 parent 6934eea commit d90b7c7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/testing/selftests/kselftest/ktap_helpers.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ ktap_test_fail() {
7676
KTAP_CNT_FAIL=$((KTAP_CNT_FAIL+1))
7777
}
7878

79+
ktap_test_result() {
80+
description="$1"
81+
shift
82+
83+
if $@; then
84+
ktap_test_pass "$description"
85+
else
86+
ktap_test_fail "$description"
87+
fi
88+
}
89+
7990
ktap_print_totals() {
8091
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
8192
}

0 commit comments

Comments
 (0)