Commit 2dd0b5a8 authored by Nícolas F. R. A. Prado's avatar Nícolas F. R. A. Prado Committed by Shuah Khan

selftests: ktap_helpers: Add a helper to finish the test

Similar to the C counterpart, keep track of the number of test cases in
the test plan and add a helper function to be called at the end of the
test to print the results and exit with the corresponding exit code.
Signed-off-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent d63fde98
...@@ -15,6 +15,8 @@ KSFT_XFAIL=2 ...@@ -15,6 +15,8 @@ KSFT_XFAIL=2
KSFT_XPASS=3 KSFT_XPASS=3
KSFT_SKIP=4 KSFT_SKIP=4
KSFT_NUM_TESTS=0
ktap_print_header() { ktap_print_header() {
echo "TAP version 13" echo "TAP version 13"
} }
...@@ -25,9 +27,9 @@ ktap_print_msg() ...@@ -25,9 +27,9 @@ ktap_print_msg()
} }
ktap_set_plan() { ktap_set_plan() {
num_tests="$1" KSFT_NUM_TESTS="$1"
echo "1..$num_tests" echo "1..$KSFT_NUM_TESTS"
} }
ktap_skip_all() { ktap_skip_all() {
...@@ -94,6 +96,16 @@ ktap_exit_fail_msg() { ...@@ -94,6 +96,16 @@ ktap_exit_fail_msg() {
exit "$KSFT_FAIL" exit "$KSFT_FAIL"
} }
ktap_finished() {
ktap_print_totals
if [ $(("$KTAP_CNT_PASS" + "$KTAP_CNT_SKIP")) -eq "$KSFT_NUM_TESTS" ]; then
exit "$KSFT_PASS"
else
exit "$KSFT_FAIL"
fi
}
ktap_print_totals() { ktap_print_totals() {
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0" echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment