aboutsummaryrefslogtreecommitdiffstats
path: root/tests/various/logger_fail.sh
blob: 19b65000718517646134ae0f36bef51cf1cbc9a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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