-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntest
More file actions
executable file
·124 lines (97 loc) · 2.33 KB
/
runtest
File metadata and controls
executable file
·124 lines (97 loc) · 2.33 KB
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
#!/bin/bash
function usage() {
echo "Usage: ${PROGNAME} test_map" >&2
exit 2
}
function die() {
echo "${PROGNAME}:" "$@" >&2
trap "" EXIT
cleanup
exit 1
}
function diecat() {
cat $1
shift
die "$@"
}
function cleanup() {
rm -fr ${TMPDIR}
}
function make_proj() {
local out=$1
local src_file=$2
local test_file=$3
cat >${out} <<EOF
vhdl work "${src_file}"
vhdl work "${test_file}"
EOF
}
function entity_from_test() {
local test_file=$1
egrep -i '^entity [^ ]* is' $test_file |awk '{print $2;}'
}
function run_test() {
local src_file=$1
local test_file=$2
local proj_file=${TMPDIR}/test.prj
make_proj ${proj_file} ${PWD}/${src_file} ${PWD}/${test_file}
local entity_name=$(entity_from_test ${test_file})
[[ -z "${entity_name}" ]] && \
die "failed to find single entity in ${test_file}"
local unit_name=work.$(entity_from_test ${test_file})
mkdir -p ${TMPDIR}/isim/work
(cd ${TMPDIR} ; fuse \
-intstyle ise \
-incremental \
-lib secureip \
-o ${TMPDIR}/test.exe \
-prj ${proj_file} \
${unit_name} >/dev/null ) || \
diecat ${TMPDIR}/fuse.log "failed to compile ${proj_file}"
local test_log=${TMPDIR}/test.log
(cd ${TMPDIR} ; ./test.exe \
-log ${test_log} \
-tclbatch ${CMDFILE} >/dev/null) || \
diecat ${test_log} "failed to run test ${proj_file}"
if grep -q '^at' ${test_log} ; then
cat ${test_log}
return 1
fi
}
PROGNAME=$(basename "$0")
SRCDIR=${PWD}
[[ -d ${SRCDIR} ]] || die "No src dir in pwd"
SYNDIR=${PWD}/syn
[[ -d ${SYNDIR} ]] || die "No syn dir in pwd"
type -P fuse >/dev/null 2>&1 || die "fuse not in PATH. ISE vars dotted?"
[[ $# -eq 1 ]] || usage
TEST_MAP="$1"
TMPDIR=$(mktemp -d)
trap "{ cleanup ; exit 0; }" EXIT
CMDFILE=${TMPDIR}/isim_cmd.tcl
cat >$CMDFILE <<EOF
wave add /
run 1000 ns
quit
EOF
num_tests=0
num_success=0
num_fail=0
while read line ; do
set -- ${line}
src_file=$1
test_file=$2
echo == ${test_file}...
run_test ${src_file} ${test_file}
if [[ $? -eq 0 ]] ; then
num_success=$((num_success + 1))
result="PASS"
else
num_fail=$((num_fail + 1))
result="FAIL"
fi
num_tests=$((num_tests + 1))
echo == ${test_file}...${result}
done <<< "$(grep -v '^#' ${TEST_MAP})"
echo "Summary: num tests: ${num_tests}; success: ${num_success}; fail: ${num_fail}"
[[ ${num_fail} -gt 1 ]] && exit 1