Commit e94c0346 by Zachary Snow

add optional error message patterns to error test suite

parent 5891a0eb
// pattern: bad default_nettype: "invalid"
`default_nettype invalid `default_nettype invalid
module top; module top;
assign foo = 0; assign foo = 0;
......
// pattern: implicit declaration of "foo" but default_nettype is none
`default_nettype none `default_nettype none
module top; module top;
assign foo = 0; assign foo = 0;
......
// pattern: enum conversion has duplicate vals
module top; module top;
typedef enum { typedef enum {
A = 0, A = 0,
......
// pattern: unexpected token 'highz1'
module top; module top;
wire (highz0, highz1) x; wire (highz0, highz1) x;
endmodule endmodule
// pattern: cannot convert expression to LHS
module top; module top;
logic x; logic x;
assign {<< {x, 2'b00}} = 3'b101; assign {<< {x, 2'b00}} = 3'b101;
......
// pattern: cannot convert expression to LHS
module top; module top;
logic x, y, z; logic x, y, z;
assign {<< {x, '{y:y, z:z}}} = 3'b101; assign {<< {x, '{y:y, z:z}}} = 3'b101;
......
// pattern: Could not find file "does_not_exist\.sv", included from "missing_include\.sv"
`include "does_not_exist.sv" `include "does_not_exist.sv"
#!/bin/bash #!/bin/bash
validateOutput() {
stdout_len=`wc -l < $SHUNIT_TMPDIR/stdout`
assertEquals "stdout should be empty" 0 $stdout_len
stderr=`cat $SHUNIT_TMPDIR/stderr`
assertNotNull "stderr should not be empty" "$stderr"
line=`head -n1 $1`
if [[ "$line" =~ \/\/\ pattern:\ .* ]]; then
pattern=${line:12}
if [[ ! "$stderr" =~ $pattern ]]; then
fail "error message doesn't match\nexpected: $pattern\nactual: $stderr"
fi
fi
}
addTest() { addTest() {
test=$1 test=$1
eval "test_$test() { \ eval "test_$test() { \
$SV2V $test.sv 2> /dev/null > /dev/null; \ $SV2V $test.sv 2> $SHUNIT_TMPDIR/stderr > $SHUNIT_TMPDIR/stdout; \
assertFalse \"conversion should have failed\" \$?; \ assertFalse \"conversion should have failed\" \$?; \
validateOutput $test.sv; \
}" }"
suite_addTest test_$test suite_addTest test_$test
} }
......
// pattern: Undefined macro: SOMETHING
`SOMETHING `SOMETHING
module top; module top;
endmodule endmodule
// pattern: `endif directive outside of an `if/`endif block
`endif `endif
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