aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/vests/testsuite.sh
blob: 4cd6e97a408441d7e49d89bcea2d45b962fd23c2 (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#! /bin/sh

. ../testenv.sh

common_args="--std=93c"

# Test number.
test_num="1"

do_inter_clean="no"

# Functions used by tests.
setup_test_group ()
{
  echo "Test: $1 $2"
}

end_test_group ()
{
  delete_lib work
  echo "*** End of tests"
}

create_lib ()
{
  echo "create library: $1"
}

delete_lib ()
{
  echo "delete library: $1"
  cmd="$GHDL --remove $common_args --work=$1"
  echo $cmd
  eval $cmd
}

# Usage: handle_test MODE FILE options...
handle_test ()
{
  mode=$1
  shift
  file=$1
  shift
  args="$common_args"
  stop=""
  entity=""
  # handle options.
  for arg; do
    case $arg in
    LIBRARY=*)
         lib=`echo $arg | sed -e s/LIBRARY=/--work=/`;
         args="$args $lib";
         ;;
    INPUT=*)
         input=$arg;
         ;;
    OUTPUT=*)
         output=$arg;
         ;;
    STOP=*)
         stop=`echo $arg | sed -e s/STOP=/--stop-time=/`;
         ;;
    ENTITY=*)
         entity=`echo $arg | sed -e s/ENTITY=//`
	 ;;
    *)
         echo "build_compliant_test: unknown argument '$arg'";
         exit 4;
         ;;
    esac
  done
  cmd="$GHDL -a $args $dir/$file"
  echo "Test: $test_num"
  echo $cmd

  if [ $test_num -gt $skip ]; then
    case $mode in
    compile)
         eval $cmd;
         ;;
    run)
         eval $cmd
         if [ x$entity = "x" ]; then
           entity=`$GET_ENTITIES $dir/$file`
	 fi
         if [ "x$entity" = "x" ]; then
           echo "Cannot elaborate or run : no top level entity";
         else
           cmd="$GHDL --elab-run $entity $stop --assert-level=error";
           echo "$cmd";
           eval $cmd;
         fi
         ;;
    ana_err)
         if eval $cmd; then
           echo "Analyze error expected";
           exit 1;
         fi
         ;;
    run_err)
         eval $cmd
#         ent=`sed -n -e "/^ENTITY \([a-zA-Z0-9]*\) IS$/p" < $dir/$file \
#              | cut -f 2 -d ' '`
         if [ x$entity = "x" ]; then
           entity=`$GET_ENTITIES $dir/$file`
	 fi
         if [ "x$entity" = "x" ]; then
           echo "Cannot elaborate or run : no top level entity";
           exit 1;
         else
           cmd="$GHDL -e $entity";
           echo "$cmd";
           eval $cmd;
           cmd="$GHDL -r $entity $stop --expect-failure --assert-level=error";
           echo "$cmd";
           eval $cmd;
         fi
         ;;
    *)
         echo "Unknown mode '$mode'";
         exit 4;
         ;;
    esac

    if [ $do_inter_clean = "yes" ]; then
      if [ `expr $test_num % 16` = "0" ]; then
         delete_lib work;
      fi
    fi
  else
    echo "skip";
  fi
  
  # Increment test_num
  test_num=`expr $test_num + 1`
}

build_compliant_test ()
{
  handle_test compile $@
}

run_non_compliant_test ()
{
   handle_test ana_err $@
}

run_compliant_test ()
{
   handle_test run $@
}


# Decode options.
skip=0

while [ $# -gt 0 ]
do
  arg=$1;
  case $arg in
    -j)  shift;
         skip=$1;
         ;;
    *) exit 1;
         ;;
  esac
  shift;
done

# Test group

dir=vhdl-93/clifton-labs/compliant
. $dir/compliant1.exp

# ashenden compliant
# OK
dir=vhdl-93/ashenden/compliant
. $dir/compliant.exp

# OK
dir=vhdl-93/ashenden/non_compliant
. $dir/non_compliant.exp


# Clean frequently the work library.
do_inter_clean="yes"

# OK.
dir=vhdl-93/billowitch/compliant
. $dir/compliant.exp


# OK but FIXMEs
dir=vhdl-93/billowitch/non_compliant/analyzer_failure
. $dir/non_compliant.exp

run_non_compliant_test ()
{
   handle_test run_err $@
}

dir=vhdl-93/billowitch/non_compliant/simulator_failure
. $dir/non_compliant.exp

delete_lib project
delete_lib random
delete_lib utilities

echo "Vests tests successful"