source: rtems/tools/build/rtems-test-check @ d2a45a58

5
Last change on this file since d2a45a58 was eb73320, checked in by Chris Johns <chrisj@…>, on 03/09/17 at 05:14:16

Fix rtems-test-check with a BSD sed.

BSD sed does not support '\t' and treated '[ \t]' as 3 characters. This patch
uses a standard method of supporting blank spaces.

  • Property mode set to 100755
File size: 3.2 KB
Line 
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
11if test $# -lt 4; then
12  echo "error: invalid command line" >&2
13  echo "INVALID-TEST-DATA"
14  exit 2
15fi
16
17mode="$1"
18shift
19testdata="$1"
20shift
21includepath="$1"
22shift
23bsp="$1"
24shift
25tests="$*"
26
27test_count=0
28for t in ${tests};
29do
30 test_count=$(expr ${test_count} + 1)
31done
32
33case ${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   ;;
53esac
54
55#
56# If there is no testdata all tests are valid and must pass.
57#
58
59if test -f $testdata; then
60  excluded_tests=""
61  expected_fails=""
62  indeterminates=""
63  while [ ! -z "$testdata" ];
64  do
65    for td in $testdata;
66    do
67      ntd=""
68      exec 3<& 0
69      exec 0<$td
70      while read line
71      do
72        line=$(echo $line | sed -e 's/#.*$//' -e '/^$/d')
73        if [ ! -z "$line" ]; then
74          state=$(echo $line | sed -e "s/:.*//g")
75          case $state in
76            include)
77              inf=$(echo $line | sed -e 's/include://g;s/[[:blank:]]//g')
78              if test -f $includepath/$inf; then
79                ntd="$includepath/$inf $ntd"
80              fi
81              ;;
82            exclude)
83              line=$(echo $line | sed -e 's/exclude://g;s/[[:blank:]]//g')
84              excluded_tests="${excluded_tests} $line"
85              ;;
86            expected-fail)
87              line=$(echo $line | sed -e 's/expected-fail://g;s/[[:blank:]]//g')
88              expected_fails="${expected_fails} $line"
89              ;;
90            indeterminate)
91              line=$(echo $line | sed -e 's/indeterminate://g;s/[[:blank:]]//g')
92              indeterminates="${indeterminates} $line"
93              ;;
94            *)
95              echo "error: invalid test state: $state in $td" 1>&2
96              echo "INVALID-TEST-DATA"
97              exit 1
98              ;;
99          esac
100        fi
101      done
102    done
103    testdata=$ntd
104  done
105
106  for t in ${tests};
107  do
108    case ${mode} in
109      exclude)
110        allow="yes"
111        for dt in ${excluded_tests};
112        do
113          if test ${t} = ${dt}; then
114            allow="no"
115          fi
116        done
117        if test ${allow} = yes; then
118          output="${output} ${t}"
119        fi
120        ;;
121      flags)
122        allow="no"
123        for et in ${expected_fails};
124        do
125          if test ${t} = ${et}; then
126            allow="yes"
127          fi
128        done
129        if test ${allow} = yes; then
130          output="-DTEST_STATE_EXPECTED_FAIL=1"
131        fi
132        allow="no"
133        for it in ${indeterminates};
134        do
135          if test ${t} = ${it}; then
136            allow="yes"
137          fi
138        done
139        if test ${allow} = yes; then
140          output="${output} -DTEST_STATE_INDETERMINATE=1"
141        fi
142        ;;
143      *)
144        echo "error: invalid mode" 1>&2
145        echo "INVALID-TEST-DATA"
146        exit 1
147        ;;
148    esac
149  done
150fi
151
152echo ${output}
153
154exit 0
Note: See TracBrowser for help on using the repository browser.