summaryrefslogtreecommitdiffstats
path: root/tools/build/rtems-test-check
blob: 3a485c7dc8b015c59f90d555d8f430eaeec82097 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /bin/sh
#
# Copyright 2014 Chris Johns <chrisj@rtems.org>
# All rights reserved
#

#
# usage: rtems-test-check <bsp-test-database> <includes> <bsp> <tests..>
#

if test $# -lt 3; then
  echo "error: invalid command line" >&2
  exit 2
fi

testdata="$1"
shift
includepath="$1"
shift
bsp="$1"
shift
tests="$*"
bsp_tests=${tests}

#
# If there is no testdata all tests are valid.
#

if test -f $testdata; then
  disabled_tests=""
  while [ ! -z $testdata ];
  do
    for td in $testdata;
    do
      ntd=""
      exec 3<& 0
      exec 0<$td
      while read line
      do
        line=$(echo $line | sed -e 's/#.*$//' -e '/^$/d')
        if [ ! -z "$line" ]; then
          include=$(echo $line | sed -e "s/include:.*/yes/g")
          if [ "$include" = "yes" ]; then
            inf=$(echo $line | sed -e "s/include://g" -e 's/^[ \t]//;s/[ \t]$//')
	    if test -f $includepath/$inf; then
              ntd="$includepath/$inf $ntd"
            fi
          else
            disabled_tests="${disabled_tests} $line"
          fi
        fi
      done
    done
    testdata=$ntd
  done

  bsp_tests=""
  for t in ${tests};
  do
    allow="yes"
    for dt in ${disabled_tests};
    do
      if test ${t} = ${dt}; then
        allow="no"
      fi
    done
    if test ${allow} = yes; then
      bsp_tests="${bsp_tests} ${t}"
    fi
  done
fi

echo ${bsp_tests}

exit 0