add error test suite

This commit is contained in:
Zachary Snow 2020-06-07 16:47:27 -04:00
parent b58cf5bf07
commit 5ed053d317
7 changed files with 45 additions and 23 deletions

View File

@ -0,0 +1,8 @@
module top;
typedef enum {
A = 0,
B, // implicitly 1
C = 1
} Enum;
Enum e;
endmodule

View File

@ -0,0 +1,3 @@
module top;
wire (highz0, highz1) x;
endmodule

14
test/error/run.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
addTest() {
test=$1
eval "test_$test() { \
$SV2V $test.sv 2> /dev/null > /dev/null; \
assertFalse \"conversion should have failed\" \$?; \
}"
suite_addTest test_$test
}
source ../lib/discover.sh
. shunit2

View File

@ -0,0 +1 @@
`endif

18
test/lib/discover.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
tests=(`basename -s .sv *.sv`)
if [ $1 ]; then
tests=(`basename -s .sv "$@"`)
shift ${#tests[@]}
fi
suite() {
for test in "${tests[@]}"; do
if [ ! -f $test.sv ]; then
echo "Could not find $test.sv"
exit 1
fi
addTest $test
done
}

View File

@ -2,31 +2,13 @@
SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"`
tests=(`ls *.sv | sed -e "s_\.sv\\\$__"`)
if [ $1 ]; then
tests=("$@")
shift ${#tests[@]}
for test in $tests; do
if [ ! -f $test.sv ]; then
echo "Could not find $test.sv"
exit 1
fi
done
fi
addTest() {
test=$1
eval "test_$test() { runTest \"$test\"; }"
suite_addTest test_$test
}
suite() {
for test in "${tests[@]}"; do
addTest $test
done
}
source $SCRIPT_DIR/functions.sh
source $SCRIPT_DIR/discover.sh
. shunit2

View File

@ -6,10 +6,6 @@ test_main() {
simulateAndCompare "reference.v" "$cv" "$SCRIPT_DIR/empty.v"
}
suite() {
suite_addTest "test_main"
}
source ../lib/functions.sh
. shunit2