[1461b648] | 1 | #! /bin/sh |
---|
| 2 | # |
---|
[eb73320] | 3 | # Copyright 2014, 2016, 2017 Chris Johns <chrisj@rtems.org> |
---|
[1461b648] | 4 | # All rights reserved |
---|
| 5 | # |
---|
| 6 | |
---|
| 7 | # |
---|
[28fda62] | 8 | # usage: rtems-test-check <mode> <bsp-test-database> <includes> <bsp> <tests..> |
---|
[1461b648] | 9 | # |
---|
| 10 | |
---|
[28fda62] | 11 | if test $# -lt 4; then |
---|
[1461b648] | 12 | echo "error: invalid command line" >&2 |
---|
[28fda62] | 13 | echo "INVALID-TEST-DATA" |
---|
[1461b648] | 14 | exit 2 |
---|
| 15 | fi |
---|
| 16 | |
---|
[28fda62] | 17 | mode="$1" |
---|
| 18 | shift |
---|
[1461b648] | 19 | testdata="$1" |
---|
| 20 | shift |
---|
[431bb85d] | 21 | includepath="$1" |
---|
| 22 | shift |
---|
[1461b648] | 23 | bsp="$1" |
---|
| 24 | shift |
---|
| 25 | tests="$*" |
---|
[28fda62] | 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) |
---|
[ac01d24] | 35 | if test -f $testdata; then |
---|
| 36 | output="" |
---|
| 37 | else |
---|
| 38 | output="${tests}" |
---|
| 39 | fi |
---|
[28fda62] | 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 |
---|
[1461b648] | 54 | |
---|
[258bda3] | 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 | |
---|
[1461b648] | 62 | # |
---|
[28fda62] | 63 | # If there is no testdata all tests are valid and must pass. |
---|
[1461b648] | 64 | # |
---|
[431bb85d] | 65 | |
---|
[258bda3] | 66 | if [ ! -z "$testdata" ]; then |
---|
[28fda62] | 67 | excluded_tests="" |
---|
| 68 | expected_fails="" |
---|
[258bda3] | 69 | user_inputs="" |
---|
[28fda62] | 70 | indeterminates="" |
---|
[258bda3] | 71 | benchmarks="" |
---|
[6442d54d] | 72 | while [ ! -z "$testdata" ]; |
---|
[1461b648] | 73 | do |
---|
[431bb85d] | 74 | for td in $testdata; |
---|
| 75 | do |
---|
[258bda3] | 76 | if [ ! -f $td ]; then |
---|
| 77 | continue |
---|
| 78 | fi |
---|
[431bb85d] | 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 |
---|
[28fda62] | 86 | state=$(echo $line | sed -e "s/:.*//g") |
---|
| 87 | case $state in |
---|
| 88 | include) |
---|
[eb73320] | 89 | inf=$(echo $line | sed -e 's/include://g;s/[[:blank:]]//g') |
---|
[28fda62] | 90 | if test -f $includepath/$inf; then |
---|
| 91 | ntd="$includepath/$inf $ntd" |
---|
| 92 | fi |
---|
| 93 | ;; |
---|
| 94 | exclude) |
---|
[eb73320] | 95 | line=$(echo $line | sed -e 's/exclude://g;s/[[:blank:]]//g') |
---|
[28fda62] | 96 | excluded_tests="${excluded_tests} $line" |
---|
| 97 | ;; |
---|
| 98 | expected-fail) |
---|
[eb73320] | 99 | line=$(echo $line | sed -e 's/expected-fail://g;s/[[:blank:]]//g') |
---|
[28fda62] | 100 | expected_fails="${expected_fails} $line" |
---|
| 101 | ;; |
---|
[258bda3] | 102 | user-input) |
---|
| 103 | line=$(echo $line | sed -e 's/user-input://g;s/[[:blank:]]//g') |
---|
| 104 | user_inputs="${user_inputs} $line" |
---|
| 105 | ;; |
---|
[28fda62] | 106 | indeterminate) |
---|
[eb73320] | 107 | line=$(echo $line | sed -e 's/indeterminate://g;s/[[:blank:]]//g') |
---|
[28fda62] | 108 | indeterminates="${indeterminates} $line" |
---|
| 109 | ;; |
---|
[258bda3] | 110 | benchmark) |
---|
| 111 | line=$(echo $line | sed -e 's/benchmark://g;s/[[:blank:]]//g') |
---|
| 112 | benchmarks="${benchmarks} $line" |
---|
| 113 | ;; |
---|
[28fda62] | 114 | *) |
---|
| 115 | echo "error: invalid test state: $state in $td" 1>&2 |
---|
| 116 | echo "INVALID-TEST-DATA" |
---|
| 117 | exit 1 |
---|
| 118 | ;; |
---|
| 119 | esac |
---|
[431bb85d] | 120 | fi |
---|
| 121 | done |
---|
| 122 | done |
---|
| 123 | testdata=$ntd |
---|
[1461b648] | 124 | done |
---|
| 125 | |
---|
| 126 | for t in ${tests}; |
---|
| 127 | do |
---|
[28fda62] | 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) |
---|
[258bda3] | 142 | allow="yes" |
---|
| 143 | for et in ${excluded_tests}; |
---|
[28fda62] | 144 | do |
---|
| 145 | if test ${t} = ${et}; then |
---|
[258bda3] | 146 | allow="no" |
---|
[28fda62] | 147 | fi |
---|
| 148 | done |
---|
[258bda3] | 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" |
---|
[28fda62] | 159 | fi |
---|
[258bda3] | 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 |
---|
[28fda62] | 191 | ;; |
---|
| 192 | *) |
---|
| 193 | echo "error: invalid mode" 1>&2 |
---|
| 194 | echo "INVALID-TEST-DATA" |
---|
| 195 | exit 1 |
---|
| 196 | ;; |
---|
| 197 | esac |
---|
[1461b648] | 198 | done |
---|
| 199 | fi |
---|
| 200 | |
---|
[28fda62] | 201 | echo ${output} |
---|
[1461b648] | 202 | |
---|
| 203 | exit 0 |
---|