Home | History | Annotate | Line # | Download | only in tests
      1  1.1  dholland test_case() {
      2  1.1  dholland 	local name="$1"
      3  1.1  dholland 	local source="$2"
      4  1.1  dholland 	local tradcpp="$3"
      5  1.1  dholland 	local descr="Test tradcpp behavior"
      6  1.1  dholland 	atf_test_case ${name}
      7  1.1  dholland 	if [ -e "$(atf_get_srcdir)/${name}.txt" ]; then
      8  1.1  dholland 		descr=$(cat "$(atf_get_srcdir)/${name}.txt")
      9  1.1  dholland 	fi
     10  1.1  dholland 	eval "${name}_head() { \
     11  1.1  dholland 		atf_set descr \"${descr}\"; \
     12  1.1  dholland 		atf_set require.progs \"/usr/bin/tradcpp\"; \
     13  1.1  dholland 	}"
     14  1.1  dholland 	local stdout="file:$(atf_get_srcdir)/${name}.good"
     15  1.1  dholland 	local options=""
     16  1.1  dholland 	local options_file="$(atf_get_srcdir)/${name}.cmdline"
     17  1.1  dholland 	if [ -e ${options_file} ]; then
     18  1.1  dholland 		options=$(cat ${options_file})
     19  1.1  dholland 	fi
     20  1.1  dholland 	eval "${name}_body() { \
     21  1.1  dholland 		atf_check -s eq:0 -o ${stdout} -x '${tradcpp} ${options} ${source} 2>&1 || echo FAILED'; \
     22  1.1  dholland 	}"
     23  1.1  dholland }
     24  1.1  dholland 
     25  1.1  dholland atf_init_test_cases() {
     26  1.1  dholland 	local tradcpp=$(make -V .OBJDIR -C $(atf_get_srcdir)/..)/tradcpp
     27  1.1  dholland 	if [ ! -x ${tradcpp} ]; then
     28  1.1  dholland 		tradcpp=/usr/bin/tradcpp
     29  1.1  dholland 	fi
     30  1.1  dholland 	cd $(atf_get_srcdir)
     31  1.1  dholland 	for testfile in t*.c; do
     32  1.1  dholland 		local name=${testfile%%.c}
     33  1.1  dholland 		test_case ${name} ${testfile} ${tradcpp}
     34  1.1  dholland 		atf_add_test_case ${name}
     35  1.1  dholland 	done
     36  1.1  dholland }
     37