diff options
| author | Zachary Snow <zach@zachjs.com> | 2022-01-03 20:12:22 -0700 | 
|---|---|---|
| committer | Zachary Snow <zachary.j.snow@gmail.com> | 2022-01-04 13:39:34 -0700 | 
| commit | 66447e8fafa53396510b9a2c789fef6e5df0d6ac (patch) | |
| tree | 37c0332a075e37259e35bd9ab9a54bf3832a9652 /tests | |
| parent | b022fe61a7e0cbe93124a5db243083e65f51fd85 (diff) | |
| download | yosys-66447e8fafa53396510b9a2c789fef6e5df0d6ac.tar.gz yosys-66447e8fafa53396510b9a2c789fef6e5df0d6ac.tar.bz2 yosys-66447e8fafa53396510b9a2c789fef6e5df0d6ac.zip  | |
logger: fix unmatched expected warnings and errors
- Prevent unmatched expected error patterns from self-matching
- Prevent infinite recursion on unmatched expected warnings
- Always print the error message for unmatched error patterns
- Add test coverage for all unmatched message types
- Add test coverage for excess matched logs and warnings
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/various/logger_fail.sh | 42 | 
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/various/logger_fail.sh b/tests/various/logger_fail.sh new file mode 100755 index 000000000..19b650007 --- /dev/null +++ b/tests/various/logger_fail.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +fail() { +	echo "$1" >&2 +	exit 1 +} + +runTest() { +	desc="$1" +	want="$2" +	shift 2 +	echo "running '$desc' with args $@" +	output=`../../yosys -q "$@" 2>&1` +	if [ $? -ne 1 ]; then +		fail "exit code for '$desc' was not 1" +	fi +	if [ "$output" != "$want" ]; then +		fail "output for '$desc' did not match" +	fi +} + +unmet() { +	kind=$1 +	runTest "unmet $kind" \ +		"ERROR: Expected $kind pattern 'foobar' not found !" \ +		-p "logger -expect $kind \"foobar\" 1" +} + +unmet log +unmet warning +unmet error + +runTest "too many logs" \ +	"ERROR: Expected log pattern 'statistics' found 2 time(s), instead of 1 time(s) !" \ +	-p "logger -expect log \"statistics\" 1" -p stat -p stat + +runTest "too many warnings" \ +	"Warning: Found log message matching -W regex: +Printing statistics. +ERROR: Expected warning pattern 'statistics' found 2 time(s), instead of 1 time(s) !" \ +	-p "logger -warn \"Printing statistics\"" \ +	-p "logger -expect warning \"statistics\" 1" -p stat -p stat  | 
