changeset 50:ce9347338583

ATF glue
author Joerg Sonnenberger <joerg@bec.de>
date Sun, 31 Mar 2013 05:39:50 +0200
parents 0af03c5571e0
children bec1eb5ac326
files tests/Makefile tests/tradcpp.sh
diffstat 2 files changed, 47 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/Makefile	Sat Mar 30 23:29:08 2013 -0400
+++ b/tests/Makefile	Sun Mar 31 05:39:50 2013 +0200
@@ -1,9 +1,18 @@
-TRADCPP=../obj/tradcpp  # XXX
+#	$NetBSD$
+
+all: run-tests .WAIT show-diffs
+
+TESTDIR=	${TESTSBASE}/usr.bin/tradcpp
+
+TESTS_SH+=	tradcpp
+
+.include <bsd.test.mk>
+
+TRADCPP_OBJDIR!=	${MAKE} -C .. -V .OBJDIR
+TRADCPP=	${TRADCPP_OBJDIR}/tradcpp
 
 TESTS=t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12
 
-all: run-tests .WAIT show-diffs
-
 .for T in $(TESTS)
 run-tests: $(T).diff
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tradcpp.sh	Sun Mar 31 05:39:50 2013 +0200
@@ -0,0 +1,35 @@
+test_case() {
+	local name="$1"
+	local source="$2"
+	local tradcpp="$3"
+	local descr="Test tradcpp behavior"
+	atf_test_case ${name}
+	if [ -e "$(atf_get_srcdir)/${name}.txt" ]; then
+		descr=$(cat "$(atf_get_srcdir)/${name}.txt")
+	fi
+	eval "${name}_head() { \
+		atf_set descr \"${descr}\"; \
+		atf_set require.progs \"/usr/bin/tradcpp\"; \
+	}"
+	local stdout="file:$(atf_get_srcdir)/${name}.good"
+	local options=""
+	local options_file="$(atf_get_srcdir)/${name}.cmdline"
+	if [ -e ${options_file} ]; then
+		options=$(cat ${options_file})
+	fi
+	eval "${name}_body() { \
+		atf_check -s eq:0 -o ${stdout} "${tradcpp} ${options} ${source} 2\>\&1"; \
+	}"
+}
+
+atf_init_test_cases() {
+	local tradcpp=$(make -V .OBJDIR -C $(atf_get_srcdir)/..)/tradcpp
+	if [ ! -x ${tradcpp} ]; then
+		tradcpp=/usr/bin/tradcpp
+	fi
+	for testfile in $(atf_get_srcdir)/t*.c; do
+		local name=$(basename ${testfile%%.c})
+		test_case ${name} ${testfile} ${tradcpp}
+		atf_add_test_case ${name}
+	done
+}