summaryrefslogtreecommitdiffstats
path: root/unit/unittest.sh.in
blob: 70335aa7b37a2c83c3b2bd8bb3117a81114c581e (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
#!/bin/sh

PATH="@ATFBIN@:${PATH}"
export PATH
ATFRUN=`command -v atf-run 2>/dev/null`
KYUA=`command -v kyua 2>/dev/null`

status=0
if [ -n "@UNITTESTS@" -a -x "$ATFRUN" -a -f Atffile ]
then
	echo "S:unit:`date`"
	echo "T:unit:1:A"
	echo "I: unit tests (using atf-run)"
	atf-run > atf.out
	status=$?

	# | cat is there to force non-fancy output
	atf-report < atf.out | cat

	if [ $status -eq 0 ]
	then
		rm -f atf.out
		echo R:PASS
	else
		echo R:FAIL
	fi
	echo "E:unit:`date`"
elif [ -n "@UNITTESTS@" -a -x "$KYUA" -a -f Kyuafile ]
then
	echo "S:unit:`date`"
	echo "T:unit:1:A"
	echo "I: unit tests (using kyua)"
	kyua -v parallelism=${TEST_PARALLEL_JOBS:-1} --logfile kyua.log --loglevel debug test --results-file ${KYUA_RESULT:-NEW}
	status=$?

	kyua report --results-file ${KYUA_RESULT:-LATEST}

	if [ $status -eq 0 ]
	then
		rm -f kyua.log
		echo R:PASS
	else
		echo R:FAIL
	fi
	echo "E:unit:`date`"
fi
exit $status