mirror of https://github.com/zachjs/sv2v.git
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
This commit is contained in:
parent
3abe12dfbd
commit
f061e88214
|
|
@ -1,4 +1,4 @@
|
|||
// 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;
|
||||
initial assert #1 (1);
|
||||
endmodule
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
runErrorTest() {
|
||||
extractFlag pattern $1.sv
|
||||
pattern="${flag:-.}"
|
||||
|
||||
runAndCapture $1.sv
|
||||
assertFalse "conversion should have failed" $result
|
||||
assertNull "stdout should be empty" "$stdout"
|
||||
assertNotNull "stderr should not be empty" "$stderr"
|
||||
line=`head -n1 $1.sv`
|
||||
if [[ "$line" =~ \/\/\ pattern:\ .* ]]; then
|
||||
pattern=${line:12}
|
||||
if [[ ! "$stderr" =~ $pattern ]]; then
|
||||
fail "error message doesn't match\nexpected: $pattern\nactual: $stderr"
|
||||
fi
|
||||
fi
|
||||
assertFalse "regular conversion should have failed" $result
|
||||
assertNull "regular stdout should be empty" "$stdout"
|
||||
assertNotNull "regular stderr should not be empty" "$stderr"
|
||||
assertMatch "regular error message" "$stderr" "$pattern"
|
||||
|
||||
runAndCapture -v $1.sv
|
||||
assertFalse "verbose conversion should have failed" $result
|
||||
assertNull "verbose stdout should be empty" "$stdout"
|
||||
assertNotNull "verbose stderr should not be empty" "$stderr"
|
||||
assertMatch "verbose error message" "$stderr" "$pattern"
|
||||
}
|
||||
|
||||
addTest() {
|
||||
|
|
|
|||
|
|
@ -3,12 +3,6 @@
|
|||
SCRIPT_DIR=`dirname "${BASH_SOURCE[0]}"`
|
||||
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> ...]
|
||||
simulate() {
|
||||
# arguments
|
||||
|
|
@ -70,17 +64,29 @@ assertConverts() {
|
|||
filtered=`sed -E 's/"([^"]|\")+"//g' $ac_tmpa`
|
||||
# check for various things iverilog accepts which we don't want to output
|
||||
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'
|
||||
assertNotMatch "$filtered" "$prefix SystemVerilog types" \
|
||||
assertNotMatch "$prefix SystemVerilog types" "$filtered" \
|
||||
'[[:space:]](int|bit|logic|byte|struct|enum|longint|shortint)[[:space:]]'
|
||||
assertNotMatch "$filtered" "$prefix unsigned keyword" \
|
||||
assertNotMatch "$prefix unsigned keyword" "$filtered" \
|
||||
'[^\$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() {
|
||||
if [[ "$1" =~ $3 ]]; then
|
||||
fail "$2"
|
||||
if [[ "$2" =~ $3 ]]; then
|
||||
fail "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue