summaryrefslogtreecommitdiff
path: root/source4/script/tests/test_functions.sh
blob: 50b581c69b5d179887487cc110a1d5d43cf921f3 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
testit() {
        name=$1
	shift 1
	trap "rm -f test.$$" EXIT
	cmdline="$*"
	if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
		echo "--==--==--==--==--==--==--==--==--==--==--"
		echo "Running test $name (level 0 stdout)"
		echo "--==--==--==--==--==--==--==--==--==--==--"
		date
		echo "Testing $name"
	else
		echo "Testing $name"
	fi
	( $cmdline > test.$$ 2>&1 )
	status=$?
	if [ x"$status" != x"0" ]; then
		cat test.$$;
		rm -f test.$$;
		if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
			echo "=========================================="
			echo "TEST FAILED: $name (status $ret)"
			echo "=========================================="
   		else
			echo "TEST FAILED: $name (status $ret)"
		fi
		return 1;
	fi
	rm -f test.$$;
	if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
		echo "ALL OK: $cmdline"
		echo "=========================================="
		echo "TEST PASSED: $name"
		echo "=========================================="
	fi
	return 0;
}

testok() {
	name=`basename $1`
	failed=$2
	if [ x"$failed" = x"0" ];then
		:
	else
		echo "$failed TESTS FAILED ($name)";
	fi
	exit $failed
}

teststatus() {
	name=`basename $1`
	failed=$2
	if [ x"$failed" = x"0" ];then
		echo "TEST STATUS: $failed";
	else
		echo "TEST STATUS: $failed";
	fi
	exit $failed
}