1 | #! /bin/sh |
---|
2 | # |
---|
3 | # Copyright 2014, 2016 Chris Johns <chrisj@rtems.org> |
---|
4 | # All rights reserved |
---|
5 | # |
---|
6 | |
---|
7 | # |
---|
8 | # usage: rtems-test-check <mode> <bsp-test-database> <includes> <bsp> <tests..> |
---|
9 | # |
---|
10 | |
---|
11 | if test $# -lt 4; then |
---|
12 | echo "error: invalid command line" >&2 |
---|
13 | echo "INVALID-TEST-DATA" |
---|
14 | exit 2 |
---|
15 | fi |
---|
16 | |
---|
17 | mode="$1" |
---|
18 | shift |
---|
19 | testdata="$1" |
---|
20 | shift |
---|
21 | includepath="$1" |
---|
22 | shift |
---|
23 | bsp="$1" |
---|
24 | shift |
---|
25 | tests="$*" |
---|
26 | |
---|
27 | test_count=0 |
---|
28 | for t in ${tests}; |
---|
29 | do |
---|
30 | test_count=$(expr ${test_count} + 1) |
---|
31 | done |
---|
32 | |
---|
33 | case ${mode} in |
---|
34 | exclude) |
---|
35 | output=${tests} |
---|
36 | ;; |
---|
37 | flags) |
---|
38 | if [ $test_count != 1 ]; then |
---|
39 | echo "error: test count not 1 for ${mode}" 1>&2 |
---|
40 | exit 1 |
---|
41 | fi |
---|
42 | output="" |
---|
43 | ;; |
---|
44 | *) |
---|
45 | echo "error: invalid mode" 1>&2 |
---|
46 | echo "INVALID-TEST-DATA" |
---|
47 | exit 1 |
---|
48 | ;; |
---|
49 | esac |
---|
50 | |
---|
51 | # |
---|
52 | # If there is no testdata all tests are valid and must pass. |
---|
53 | # |
---|
54 | |
---|
55 | if test -f $testdata; then |
---|
56 | excluded_tests="" |
---|
57 | expected_fails="" |
---|
58 | indeterminates="" |
---|
59 | while [ ! -z "$testdata" ]; |
---|
60 | do |
---|
61 | for td in $testdata; |
---|
62 | do |
---|
63 | ntd="" |
---|
64 | exec 3<& 0 |
---|
65 | exec 0<$td |
---|
66 | while read line |
---|
67 | do |
---|
68 | line=$(echo $line | sed -e 's/#.*$//' -e '/^$/d') |
---|
69 | if [ ! -z "$line" ]; then |
---|
70 | state=$(echo $line | sed -e "s/:.*//g") |
---|
71 | case $state in |
---|
72 | include) |
---|
73 | inf=$(echo $line | sed -e "s/include://g" -e 's/^[ \t]//;s/[ \t]$//') |
---|
74 | if test -f $includepath/$inf; then |
---|
75 | ntd="$includepath/$inf $ntd" |
---|
76 | fi |
---|
77 | ;; |
---|
78 | exclude) |
---|
79 | line=$(echo $line | sed -e "s/exclude://g" -e 's/^[ \t]//;s/[ \t]$//') |
---|
80 | excluded_tests="${excluded_tests} $line" |
---|
81 | ;; |
---|
82 | expected-fail) |
---|
83 | line=$(echo $line | sed -e "s/expected-fail://g" -e 's/^[ \t]//;s/[ \t]$//') |
---|
84 | expected_fails="${expected_fails} $line" |
---|
85 | ;; |
---|
86 | indeterminate) |
---|
87 | line=$(echo $line | sed -e "s/indeterminate://g" -e 's/^[ \t]//;s/[ \t]$//') |
---|
88 | indeterminates="${indeterminates} $line" |
---|
89 | ;; |
---|
90 | *) |
---|
91 | echo "error: invalid test state: $state in $td" 1>&2 |
---|
92 | echo "INVALID-TEST-DATA" |
---|
93 | exit 1 |
---|
94 | ;; |
---|
95 | esac |
---|
96 | fi |
---|
97 | done |
---|
98 | done |
---|
99 | testdata=$ntd |
---|
100 | done |
---|
101 | |
---|
102 | for t in ${tests}; |
---|
103 | do |
---|
104 | case ${mode} in |
---|
105 | exclude) |
---|
106 | allow="yes" |
---|
107 | for dt in ${excluded_tests}; |
---|
108 | do |
---|
109 | if test ${t} = ${dt}; then |
---|
110 | allow="no" |
---|
111 | fi |
---|
112 | done |
---|
113 | if test ${allow} = yes; then |
---|
114 | output="${output} ${t}" |
---|
115 | fi |
---|
116 | ;; |
---|
117 | flags) |
---|
118 | allow="no" |
---|
119 | for et in ${expected_fails}; |
---|
120 | do |
---|
121 | if test ${t} = ${et}; then |
---|
122 | allow="yes" |
---|
123 | fi |
---|
124 | done |
---|
125 | if test ${allow} = yes; then |
---|
126 | output="-DTEST_STATE_EXPECTED_FAIL=1" |
---|
127 | fi |
---|
128 | allow="no" |
---|
129 | for it in ${indeterminates}; |
---|
130 | do |
---|
131 | if test ${t} = ${it}; then |
---|
132 | allow="yes" |
---|
133 | fi |
---|
134 | done |
---|
135 | if test ${allow} = yes; then |
---|
136 | output="${output} -DTEST_STATE_INDETERMINATE=1" |
---|
137 | fi |
---|
138 | ;; |
---|
139 | *) |
---|
140 | echo "error: invalid mode" 1>&2 |
---|
141 | echo "INVALID-TEST-DATA" |
---|
142 | exit 1 |
---|
143 | ;; |
---|
144 | esac |
---|
145 | done |
---|
146 | fi |
---|
147 | |
---|
148 | echo ${output} |
---|
149 | |
---|
150 | exit 0 |
---|