blob: 79a125eb24c2e8a0539a367a05f46d996d9164f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2023 Collabora Ltd
#
# Helpers for outputting in KTAP format
#
KTAP_TESTNO=1
KTAP_CNT_PASS=0
KTAP_CNT_FAIL=0
KTAP_CNT_SKIP=0
KSFT_PASS=0
KSFT_FAIL=1
KSFT_XFAIL=2
KSFT_XPASS=3
KSFT_SKIP=4
KSFT_NUM_TESTS=0
ktap_print_header() {
echo "TAP version 13"
}
ktap_print_msg()
{
echo "#" $@
}
ktap_set_plan() {
KSFT_NUM_TESTS="$1"
echo "1..$KSFT_NUM_TESTS"
}
ktap_skip_all() {
echo -n "1..0 # SKIP "
echo $@
}
__ktap_test() {
result="$1"
description="$2"
directive="$3" # optional
local directive_str=
[ ! -z "$directive" ] && directive_str="# $directive"
echo $result $KTAP_TESTNO $description $directive_str
KTAP_TESTNO=$((KTAP_TESTNO+1))
}
ktap_test_pass() {
description="$1"
result="ok"
__ktap_test "$result" "$description"
KTAP_CNT_PASS=$((KTAP_CNT_PASS+1))
}
ktap_test_skip() {
description="$1"
result="ok"
directive="SKIP"
__ktap_test "$result" "$description" "$directive"
KTAP_CNT_SKIP=$((KTAP_CNT_SKIP+1))
}
ktap_test_fail() {
description="$1"
result="not ok"
__ktap_test "$result" "$description"
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_exit_fail_msg() {
echo "Bail out! " $@
ktap_print_totals
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() {
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
}
|