1 | #! /bin/sh |
---|
2 | # |
---|
3 | # Copyright 2014, 2016, 2017 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 | if test -f $testdata; then |
---|
36 | output="" |
---|
37 | else |
---|
38 | output="${tests}" |
---|
39 | fi |
---|
40 | ;; |
---|
41 | flags) |
---|
42 | if [ $test_count != 1 ]; then |
---|
43 | echo "error: test count not 1 for ${mode}" 1>&2 |
---|
44 | exit 1 |
---|
45 | fi |
---|
46 | output="" |
---|
47 | ;; |
---|
48 | *) |
---|
49 | echo "error: invalid mode" 1>&2 |
---|
50 | echo "INVALID-TEST-DATA" |
---|
51 | exit 1 |
---|
52 | ;; |
---|
53 | esac |
---|
54 | |
---|
55 | # |
---|
56 | # Read the common settings first. |
---|
57 | # |
---|
58 | if [ -f $includepath/testdata/rtems.tcfg ]; then |
---|
59 | testdata="$includepath/testdata/rtems.tcfg $testdata" |
---|
60 | fi |
---|
61 | |
---|
62 | # |
---|
63 | # If there is no testdata all tests are valid and must pass. |
---|
64 | # |
---|
65 | |
---|
66 | if [ ! -z "$testdata" ]; then |
---|
67 | excluded_tests="" |
---|
68 | expected_fails="" |
---|
69 | user_inputs="" |
---|
70 | indeterminates="" |
---|
71 | benchmarks="" |
---|
72 | while [ ! -z "$testdata" ]; |
---|
73 | do |
---|
74 | for td in $testdata; |
---|
75 | do |
---|
76 | if [ ! -f $td ]; then |
---|
77 | continue |
---|
78 | fi |
---|
79 | ntd="" |
---|
80 | exec 3<& 0 |
---|
81 | exec 0<$td |
---|
82 | while read line |
---|
83 | do |
---|
84 | line=$(echo $line | sed -e 's/#.*$//' -e '/^$/d') |
---|
85 | if [ ! -z "$line" ]; then |
---|
86 | state=$(echo $line | sed -e "s/:.*//g") |
---|
87 | case $state in |
---|
88 | include) |
---|
89 | inf=$(echo $line | sed -e 's/include://g;s/[[:blank:]]//g') |
---|
90 | if test -f $includepath/$inf; then |
---|
91 | ntd="$includepath/$inf $ntd" |
---|
92 | fi |
---|
93 | ;; |
---|
94 | exclude) |
---|
95 | line=$(echo $line | sed -e 's/exclude://g;s/[[:blank:]]//g') |
---|
96 | excluded_tests="${excluded_tests} $line" |
---|
97 | ;; |
---|
98 | expected-fail) |
---|
99 | line=$(echo $line | sed -e 's/expected-fail://g;s/[[:blank:]]//g') |
---|
100 | expected_fails="${expected_fails} $line" |
---|
101 | ;; |
---|
102 | user-input) |
---|
103 | line=$(echo $line | sed -e 's/user-input://g;s/[[:blank:]]//g') |
---|
104 | user_inputs="${user_inputs} $line" |
---|
105 | ;; |
---|
106 | indeterminate) |
---|
107 | line=$(echo $line | sed -e 's/indeterminate://g;s/[[:blank:]]//g') |
---|
108 | indeterminates="${indeterminates} $line" |
---|
109 | ;; |
---|
110 | benchmark) |
---|
111 | line=$(echo $line | sed -e 's/benchmark://g;s/[[:blank:]]//g') |
---|
112 | benchmarks="${benchmarks} $line" |
---|
113 | ;; |
---|
114 | *) |
---|
115 | echo "error: invalid test state: $state in $td" 1>&2 |
---|
116 | echo "INVALID-TEST-DATA" |
---|
117 | exit 1 |
---|
118 | ;; |
---|
119 | esac |
---|
120 | fi |
---|
121 | done |
---|
122 | done |
---|
123 | testdata=$ntd |
---|
124 | done |
---|
125 | |
---|
126 | for t in ${tests}; |
---|
127 | do |
---|
128 | case ${mode} in |
---|
129 | exclude) |
---|
130 | allow="yes" |
---|
131 | for dt in ${excluded_tests}; |
---|
132 | do |
---|
133 | if test ${t} = ${dt}; then |
---|
134 | allow="no" |
---|
135 | fi |
---|
136 | done |
---|
137 | if test ${allow} = yes; then |
---|
138 | output="${output} ${t}" |
---|
139 | fi |
---|
140 | ;; |
---|
141 | flags) |
---|
142 | allow="yes" |
---|
143 | for et in ${excluded_tests}; |
---|
144 | do |
---|
145 | if test ${t} = ${et}; then |
---|
146 | allow="no" |
---|
147 | fi |
---|
148 | done |
---|
149 | if test ${allow} = yes; then |
---|
150 | allow="no" |
---|
151 | for et in ${expected_fails}; |
---|
152 | do |
---|
153 | if test ${t} = ${et}; then |
---|
154 | allow="yes" |
---|
155 | fi |
---|
156 | done |
---|
157 | if test ${allow} = yes; then |
---|
158 | output="-DTEST_STATE_EXPECTED_FAIL=1" |
---|
159 | fi |
---|
160 | allow="no" |
---|
161 | for ut in ${user_inputs}; |
---|
162 | do |
---|
163 | if test ${t} = ${ut}; then |
---|
164 | allow="yes" |
---|
165 | fi |
---|
166 | done |
---|
167 | if test ${allow} = yes; then |
---|
168 | output="-DTEST_STATE_USER_INPUT=1" |
---|
169 | fi |
---|
170 | allow="no" |
---|
171 | for it in ${indeterminates}; |
---|
172 | do |
---|
173 | if test ${t} = ${it}; then |
---|
174 | allow="yes" |
---|
175 | fi |
---|
176 | done |
---|
177 | if test ${allow} = yes; then |
---|
178 | output="${output} -DTEST_STATE_INDETERMINATE=1" |
---|
179 | fi |
---|
180 | allow="no" |
---|
181 | for bt in ${benchmarks}; |
---|
182 | do |
---|
183 | if test ${t} = ${bt}; then |
---|
184 | allow="yes" |
---|
185 | fi |
---|
186 | done |
---|
187 | if test ${allow} = yes; then |
---|
188 | output="${output} -DTEST_STATE_BENCHMARK=1" |
---|
189 | fi |
---|
190 | fi |
---|
191 | ;; |
---|
192 | *) |
---|
193 | echo "error: invalid mode" 1>&2 |
---|
194 | echo "INVALID-TEST-DATA" |
---|
195 | exit 1 |
---|
196 | ;; |
---|
197 | esac |
---|
198 | done |
---|
199 | fi |
---|
200 | |
---|
201 | echo ${output} |
---|
202 | |
---|
203 | exit 0 |
---|