Mercurial > ~dholland > hg > tradcpp > index.cgi
changeset 59:a52f0229f22b
Merge.
author | David A. Holland |
---|---|
date | Sun, 31 Mar 2013 01:17:45 -0400 |
parents | 0cd5a1d55ed6 (diff) 8a204d153398 (current diff) |
children | bf39ba646885 |
files | tests/Makefile |
diffstat | 10 files changed, 81 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/Makefile Sun Mar 31 01:04:43 2013 -0400 +++ b/tests/Makefile Sun Mar 31 01:17:45 2013 -0400 @@ -1,6 +1,9 @@ -TRADCPP=../obj/tradcpp # XXX +TRADCPP_OBJDIR!= ${MAKE} -C .. -V .OBJDIR +TRADCPP= ${TRADCPP_OBJDIR}/tradcpp -TESTS=t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 +TESTS=\ + t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 \ + t17 t18 t19 all: run-tests .WAIT show-diffs @@ -31,3 +34,11 @@ .endfor .PHONY: all run-tests show-diffs clean good + +############################################################ + +.if defined(ALLOW_BROKEN_ATF_POLLUTION) +TESTDIR= ${TESTSBASE}/usr.bin/tradcpp +TESTS_SH+= tradcpp +.include <bsd.test.mk> +.endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/subdir/test.h Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,1 @@ +hello
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t16.c Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,11 @@ +#define a() x +a() +a () +#define b(p) p +x/**/b(1)/**/x +x/**/b (1)/**/x +x/**/b()/**/x +#define c(p,q) p/**/q +x/**/c(1,2)/**/x +x/**/c(1)/**/x +x/**/c()/**/x
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t16.good Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,11 @@ +x +x +x1x +x1x +xx +x12x +t16.c:10:1: Wrong number of arguments for macro c; found 1, expected 2 +x1x +t16.c:11:1: Wrong number of arguments for macro c; found 0, expected 2 +xx +FAILED
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t17.c Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,2 @@ +#define file "subdir/test.h" +#include file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t17.good Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,1 @@ +hello
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t18.c Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,2 @@ +#if FOO /* ignore me */ +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t19.c Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,3 @@ +#define foo /* comment continues + into the next line */ baz +baz
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/t19.good Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,1 @@ +baz
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/tradcpp.sh Sun Mar 31 01:17:45 2013 -0400 @@ -0,0 +1,36 @@ +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} -x '${tradcpp} ${options} ${source} 2>&1 || echo FAILED'; \ + }" +} + +atf_init_test_cases() { + local tradcpp=$(make -V .OBJDIR -C $(atf_get_srcdir)/..)/tradcpp + if [ ! -x ${tradcpp} ]; then + tradcpp=/usr/bin/tradcpp + fi + cd $(atf_get_srcdir) + for testfile in t*.c; do + local name=${testfile%%.c} + test_case ${name} ${testfile} ${tradcpp} + atf_add_test_case ${name} + done +}