blob: f060e763c345836753c67bc343bc31d5067b6267 (
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
#! /bin/bash
# Stop in case of error
set -e
enable_color() {
ENABLECOLOR=''
ANSI_RED="\033[31m"
ANSI_GREEN="\033[32m"
ANSI_YELLOW="\033[33m"
ANSI_BLUE="\033[34m"
ANSI_MAGENTA="\033[35m"
ANSI_GRAY="\033[90m"
ANSI_CYAN="\033[36;1m"
ANSI_DARKCYAN="\033[36m"
ANSI_NOCOLOR="\033[0m"
}
disable_color() { unset ENABLECOLOR ANSI_RED ANSI_GREEN ANSI_YELLOW ANSI_BLUE ANSI_MAGENTA ANSI_CYAN ANSI_DARKCYAN ANSI_NOCOLOR; }
enable_color
print_start() {
COL="$ANSI_YELLOW"
if [ "x$2" != "x" ]; then
COL="$2"
fi
printf "${COL}${1}$ANSI_NOCOLOR\n"
}
gstart () {
print_start "$@"
}
gend () {
:
}
if [ -n "$TRAVIS" ]; then
echo "INFO: set 'gstart' and 'gend' for TRAVIS"
# This is a trimmed down copy of https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/*
travis_time_start() {
# `date +%N` returns the date in nanoseconds. It is used as a replacement for $RANDOM, which is only available in bash.
travis_timer_id=`date +%N`
travis_start_time=$(travis_nanoseconds)
echo "travis_time:start:$travis_timer_id"
}
travis_time_finish() {
travis_end_time=$(travis_nanoseconds)
local duration=$(($travis_end_time-$travis_start_time))
echo "travis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration"
}
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
travis_nanoseconds() {
date -u '+%s000000000'
}
else
travis_nanoseconds() {
date -u '+%s%N'
}
fi
gstart () {
echo "travis_fold:start:group"
travis_time_start
print_start "$@"
}
gend () {
travis_time_finish
echo "travis_fold:end:group"
}
else
if [ -n "$CI" ]; then
echo "INFO: set 'gstart' and 'gend' for CI"
gstart () {
printf '::group::'
print_start "$@"
SECONDS=0
}
gend () {
duration=$SECONDS
echo '::endgroup::'
printf "${ANSI_GRAY}took $(($duration / 60)) min $(($duration % 60)) sec.${ANSI_NOCOLOR}\n"
}
fi
fi
#---
do_sanity () {
gstart "[GHDL - test] sanity"
cd sanity
for d in [0-9]*; do
cd $d
if ./testsuite.sh > test.log 2>&1 ; then
printf "sanity $d: ${ANSI_GREEN}ok${ANSI_NOCOLOR}\n"
# Don't disp log
else
printf "sanity $d: ${ANSI_RED}failed${ANSI_NOCOLOR}\n"
cat test.log
failures="$failures $d"
fi
cd ..
# Stop at the first failure
[ "$failures" = "" ] || break
done
cd ..
gend
[ "$failures" = "" ] || exit 1
}
# The GNA testsuite: regression testsuite using reports/issues from gna.org
do_gna () {
gstart "[GHDL - test] gna"
cd gna
dirs=`./testsuite.sh --list-tests`
for d in $dirs; do
cd $d
if ./testsuite.sh > test.log 2>&1 ; then
printf "gna $d: ${ANSI_GREEN}ok${ANSI_NOCOLOR}\n"
# Don't disp log
else
printf "gna $d: ${ANSI_RED}failed${ANSI_NOCOLOR}\n"
cat test.log
failures="$failures $d"
fi
cd ..
# Stop at the first failure
[ "$failures" = "" ] || break
done
cd ..
gend
[ "$failures" = "" ] || exit 1
}
# The VESTS testsuite: compliance testsuite, from: https://github.com/nickg/vests.git 388250486a
do_vests () {
gstart "[GHDL - test] vests"
cd vests
if ./testsuite.sh > vests.log 2>&1 ; then
printf "${ANSI_GREEN}Vests is OK$ANSI_NOCOLOR\n"
wc -l vests.log
else
cat vests.log
printf "${ANSI_RED}Vests failure$ANSI_NOCOLOR\n"
failures=vests
fi
cd ..
gend
[ "$failures" = "" ] || exit 1
}
do_synth () {
gstart "[GHDL - test] synth"
cd synth
if ./testsuite.sh > synth.log 2>&1 ; then
printf "${ANSI_GREEN}Synth is OK$ANSI_NOCOLOR\n"
wc -l synth.log
else
cat synth.log
printf "${ANSI_RED}Synth failure$ANSI_NOCOLOR\n"
failures="synth"
fi
cd ..
gend
[ "$failures" = "" ] || exit 1
}
#---
do_vpi () {
gstart "[GHDL - test] vpi"
cd vpi
for d in *[0-9]; do
cd $d
if ./testsuite.sh > test.log 2>&1 ; then
printf "vpi $d: ${ANSI_GREEN}ok${ANSI_NOCOLOR}\n"
# Don't disp log
else
printf "vpi $d: ${ANSI_RED}failed${ANSI_NOCOLOR}\n"
cat test.log
failures="$failures $d"
fi
cd ..
# Stop at the first failure
[ "$failures" = "" ] || break
done
cd ..
gend
[ "$failures" = "" ] || exit 1
}
#---
if [ "x$GHDL" = "x" ]; then
if [ "x$prefix" != "x" ]; then
export GHDL="$prefix/bin/ghdl"
elif [ "x$(command -v which)" != "x" ]; then
export GHDL="$(which ghdl)"
else
printf "${ANSI_RED}error: GHDL environment variable is not defined${ANSI_NOCOLOR}\n"
exit 1
fi
fi
cd $(dirname $0)
rm -f test_ok
failures=""
tests=
for opt; do
case "$opt" in
[a-z]*) tests="$tests $opt" ;;
*) echo "$0: unknown option $opt"; exit 2 ;;
esac
done
if [ "x$tests" = "x" ]; then tests="sanity gna vests synth vpi"; fi
echo "tests: $tests"
# Run a testsuite
do_test() {
case $1 in
sanity) do_sanity;;
gna) do_gna;;
vests) do_vests;;
synth) do_synth;;
vpi) do_vpi;;
*)
printf "${ANSI_RED}$0: test name '$1' is unknown${ANSI_NOCOLOR}\n"
exit 1;;
esac
}
for t in $tests; do do_test $t; done
printf "${ANSI_GREEN}[GHDL - test] SUCCESSFUL${ANSI_NOCOLOR}\n"
touch test_ok
printf "GHDL is: %s\n\n" "$GHDL"
$GHDL --version
|