Commit f061e882 by Zachary Snow

cleanup error suite infrastructure

- error suite runs in both regular and verbose mode
- add helper for extracting "flags" from test files
- common assertMatch, assertNotMatch helpers
- remove unused assertExists helper
- fix un-escaped wildcard in assert_deferred_nonzero.sv
parent 3abe12df
// pattern: assert_deferred_nonzero.sv:3:21: Parse error: expected 0 after #, but found 1 // pattern: assert_deferred_nonzero\.sv:3:21: Parse error: expected 0 after #, but found 1
module top; module top;
initial assert #1 (1); initial assert #1 (1);
endmodule endmodule
#!/bin/bash #!/bin/bash
runErrorTest() { runErrorTest() {
extractFlag pattern $1.sv
pattern="${flag:-.}"
runAndCapture $1.sv runAndCapture $1.sv
assertFalse "conversion should have failed" $result assertFalse "regular conversion should have failed" $result
assertNull "stdout should be empty" "$stdout" assertNull "regular stdout should be empty" "$stdout"
assertNotNull "stderr should not be empty" "$stderr" assertNotNull "regular stderr should not be empty" "$stderr"
line=`head -n1 $1.sv` assertMatch "regular error message" "$stderr" "$pattern"
if [[ "$line" =~ \/\/\ pattern:\ .* ]]; then
pattern=${line:12} runAndCapture -v $1.sv
if [[ ! "$stderr" =~ $pattern ]]; then assertFalse "verbose conversion should have failed" $result
fail "error message doesn't match\nexpected: $pattern\nactual: $stderr" assertNull "verbose stdout should be empty" "$stdout"
fi assertNotNull "verbose stderr should not be empty" "$stderr"
fi assertMatch "verbose error message" "$stderr" "$pattern"
} }
addTest() { addTest() {
......
...@@ -3,12 +3,6 @@ ...@@ -3,12 +3,6 @@
SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"` SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"`
SV2V="$SCRIPT_DIR/../../bin/sv2v +RTS -N1 -RTS" SV2V="$SCRIPT_DIR/../../bin/sv2v +RTS -N1 -RTS"
assertExists() {
file=$1
[ -f "$file" ]
assertTrue "$file does not exist" $?
}
# USAGE: simulate <vcd-file> <log-file> <top-module> <file> [<file> ...] # USAGE: simulate <vcd-file> <log-file> <top-module> <file> [<file> ...]
simulate() { simulate() {
# arguments # arguments
...@@ -70,17 +64,29 @@ assertConverts() { ...@@ -70,17 +64,29 @@ assertConverts() {
filtered=`sed -E 's/"([^"]|\")+"//g' $ac_tmpa` filtered=`sed -E 's/"([^"]|\")+"//g' $ac_tmpa`
# check for various things iverilog accepts which we don't want to output # check for various things iverilog accepts which we don't want to output
prefix="conversion of $ac_file still contains" prefix="conversion of $ac_file still contains"
assertNotMatch "$filtered" "$prefix dimension queries" \ assertNotMatch "$prefix dimension queries" "$filtered" \
'\$bits|\$dimensions|\$unpacked_dimensions|\$left|\$right|\$low|\$high|\$increment|\$size' '\$bits|\$dimensions|\$unpacked_dimensions|\$left|\$right|\$low|\$high|\$increment|\$size'
assertNotMatch "$filtered" "$prefix SystemVerilog types" \ assertNotMatch "$prefix SystemVerilog types" "$filtered" \
'[[:space:]](int|bit|logic|byte|struct|enum|longint|shortint)[[:space:]]' '[[:space:]](int|bit|logic|byte|struct|enum|longint|shortint)[[:space:]]'
assertNotMatch "$filtered" "$prefix unsigned keyword" \ assertNotMatch "$prefix unsigned keyword" "$filtered" \
'[^\$a-zA-Z_]unsigned' '[^\$a-zA-Z_]unsigned'
} }
extractFlag() {
raw_line=`grep -m1 "^\/\/ $1: " $2`
to_drop=$((${#1}+5))
flag="${raw_line:to_drop}"
}
assertMatch() {
if [[ ! "$2" =~ $3 ]]; then
fail "$1 doesn't match\nexpected: $3\nactual: $2"
fi
}
assertNotMatch() { assertNotMatch() {
if [[ "$1" =~ $3 ]]; then if [[ "$2" =~ $3 ]]; then
fail "$2" fail "$1"
fi fi
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment