e5f6b8
From cb616c6d5c2ece1fac37fa6e0bca2b53d4043098 Mon Sep 17 00:00:00 2001
e5f6b8
From: Mark Andrews <marka@isc.org>
e5f6b8
Date: Tue, 2 Jan 2018 10:20:58 +1100
e5f6b8
Subject: [PATCH] 4851.   [port]          Support using kyua as well as atf-run
e5f6b8
 to run the unit                         tests. [RT #46853]
e5f6b8
e5f6b8
(cherry picked from commit ccb5678066ea0055012352df5011ce2aa44e0eb0)
e5f6b8
---
e5f6b8
 unit/unittest.sh.in | 26 +++++++++++++++++++++++---
e5f6b8
 1 file changed, 23 insertions(+), 3 deletions(-)
e5f6b8
e5f6b8
diff --git a/unit/unittest.sh.in b/unit/unittest.sh.in
e5f6b8
index 899e00e..de304c6 100644
e5f6b8
--- a/unit/unittest.sh.in
e5f6b8
+++ b/unit/unittest.sh.in
e5f6b8
@@ -2,17 +2,19 @@
e5f6b8
 
e5f6b8
 PATH="@ATFBIN@:${PATH}"
e5f6b8
 export PATH
e5f6b8
+ATFRUN=`type atf-run 2>/dev/null | awk '{print $3}'`
e5f6b8
+KYUA=`type kyua 2>/dev/null | awk '{print $3}'`
e5f6b8
 
e5f6b8
 status=0
e5f6b8
-if [ -n "@ATFBIN@" -a -f Atffile ]
e5f6b8
+if [ -n "@UNITTESTS@" -a -x "$ATFRUN" -a -f Atffile ]
e5f6b8
 then
e5f6b8
 	echo "S:unit:`date`"
e5f6b8
-        echo "T:unit:1:A"
e5f6b8
+	echo "T:unit:1:A"
e5f6b8
 	echo "I: unit tests"
e5f6b8
 	atf-run > atf.out
e5f6b8
 	status=$?
e5f6b8
 
e5f6b8
-        # | cat is there to force non-fancy output
e5f6b8
+	# | cat is there to force non-fancy output
e5f6b8
 	atf-report < atf.out | cat
e5f6b8
 
e5f6b8
 	if [ $status -eq 0 ]
e5f6b8
@@ -23,5 +25,23 @@ then
e5f6b8
 		echo R:FAIL
e5f6b8
 	fi
e5f6b8
 	echo "E:unit:`date`"
e5f6b8
+elif [ -n "@UNITTESTS@" -a -x "$KYUA" -a -f Kyuafile ]
e5f6b8
+then
e5f6b8
+	echo "S:unit:`date`"
e5f6b8
+	echo "T:unit:1:A"
e5f6b8
+	echo "I: unit tests"
e5f6b8
+	kyua --logfile kyua.log test
e5f6b8
+	status=$?
e5f6b8
+
e5f6b8
+	kyua report
e5f6b8
+
e5f6b8
+	if [ $status -eq 0 ]
e5f6b8
+	then
e5f6b8
+		rm -f kyua.log
e5f6b8
+		echo R:PASS
e5f6b8
+	else
e5f6b8
+		echo R:FAIL
e5f6b8
+	fi
e5f6b8
+	echo "E:unit:`date`"
e5f6b8
 fi
e5f6b8
 exit $status
e5f6b8
-- 
e5f6b8
2.9.5
e5f6b8