summaryrefslogtreecommitdiff
path: root/tests.sh
blob: b6e25e0ea912da04747ee14db10e7e2d1c3095ec (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
43
44
45
#!/do/not/execute

DIFF=$(which diff)
GREP=$(which grep)
PTFTOOL=../../ptftool

run_test() {
	echo "$NAME"
	if [ "x$FILE" != "x" ] && [ ! -e $FILE ]; then
		echo "Cannot find test file"
		echo ""
		exit 1
	fi
	if [ "x$DIFF" != "x" ] && [ ! -e $DIFF ]; then
		echo "Cannot find diff"
		echo ""
		exit 1
	fi
	if [ "x$GREP" != "x" ] && [ ! -e $GREP ]; then
		echo "Cannot find grep"
		echo ""
		exit 1
	fi
	if [ ! -e $PTFTOOL ]; then
		echo "Cannot find ptftool"
		echo ""
		exit 1
	fi
	TMP1=$(mktemp)
	TMP2=$(mktemp)
	$PTFTOOL $FILE > $TMP1
	echo "$EXPECT" > $TMP2
	DIFFED=$($DIFF -U0 $TMP2 $TMP1 | $GREP -v -E '^\+\+\+ |^--- ')
	rm -f $TMP1 $TMP2
	if [ -z "$DIFFED" ]; then
		echo "[ OK ]"
		echo ""
		exit 0
	else
		echo "$DIFFED"
		echo "[FAIL]"
		echo ""
		exit 1
	fi
}