summaryrefslogtreecommitdiff
path: root/tests/run_script_test.sh
blob: 21c4e040b0c7c057ba89c3db84d176328e22d474 (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

input=$1

input=${input#*/tests/scripts/}
expected=${input%%/*}
ext=${input##*.}

check()
{
	status=$1
	case $status in
		0|1)
			;;
		*)
			exit 99
			;;
	esac

	case $expected in
		bad)
			[ "$status" -eq 1 ]
			;;
		*)
			[ "$status" -eq 0 ]
			;;
	esac
	if [ "$?" -ne 0 ]; then
		exit 1
	fi
}

case $expected in
	good)
		export APLWC_FAILSIM_STRICT=1
		;;
	bad)
		export APLWC_FAILSIM_STRICT=0
		;;
esac

if [ -x "$1" ]
then
	"$1"
	check $?
fi

case "$ext" in
	aplwc)
		aplwc -x "$1"
		check $?

		if [ -f "$1.output" ]
		then
			aplwc -x "$1" 2>&1 | cmp - "$1.output"
			if [ "$?" -ne 0 ]
			then
				exit 1
			fi
		fi
		;;
esac

case $expected in
	*)
		"$srcdir/tests/scripts/simfail.sh" "$1"
		check $?
esac