source: rtems/tools/build/rtems-test-check @ 28fda62

5
Last change on this file since 28fda62 was 28fda62, checked in by Chris Johns <chrisj@…>, on 12/05/16 at 03:53:54

testsuite: Add test states to the testsuit configuration files.

Change the testsuite configuration files to hold state information about
a test. The states are:

exclude - Do not build the test
expected-fail - The test is expected to fail
indeterminate - The test may pass or may fail

A message is printed just after the test's BEGIN message to indicate
there is a special state for the test. No state message means the test
is expected to pass.

This support requires tests are correctly written to the use standard
support to begin and end a test.

  • Property mode set to 100755
File size: 3.1 KB
Line 
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
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   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   ;;
49esac
50
51#
52# If there is no testdata all tests are valid and must pass.
53#
54
55if 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
146fi
147
148echo ${output}
149
150exit 0
Note: See TracBrowser for help on using the repository browser.