xref: /freebsd/usr.bin/awk/tests/bugs-fixed/bug_fix_test.sh (revision 517e52b6c21ccff22c46df0dcd15c19baee3d86c)
1*517e52b6SWarner Losh#
2*517e52b6SWarner Losh# Copyright 2014 EMC Corp.
3*517e52b6SWarner Losh# All rights reserved.
4*517e52b6SWarner Losh#
5*517e52b6SWarner Losh# Redistribution and use in source and binary forms, with or without
6*517e52b6SWarner Losh# modification, are permitted provided that the following conditions are
7*517e52b6SWarner Losh# met:
8*517e52b6SWarner Losh#
9*517e52b6SWarner Losh# * Redistributions of source code must retain the above copyright
10*517e52b6SWarner Losh#   notice, this list of conditions and the following disclaimer.
11*517e52b6SWarner Losh# * Redistributions in binary form must reproduce the above copyright
12*517e52b6SWarner Losh#   notice, this list of conditions and the following disclaimer in the
13*517e52b6SWarner Losh#   documentation and/or other materials provided with the distribution.
14*517e52b6SWarner Losh#
15*517e52b6SWarner Losh# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16*517e52b6SWarner Losh# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17*517e52b6SWarner Losh# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18*517e52b6SWarner Losh# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19*517e52b6SWarner Losh# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20*517e52b6SWarner Losh# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21*517e52b6SWarner Losh# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22*517e52b6SWarner Losh# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23*517e52b6SWarner Losh# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24*517e52b6SWarner Losh# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25*517e52b6SWarner Losh# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*517e52b6SWarner Losh#
27*517e52b6SWarner Losh# $FreeBSD$
28*517e52b6SWarner Losh
29*517e52b6SWarner LoshSRCDIR=$(atf_get_srcdir)
30*517e52b6SWarner Losh
31*517e52b6SWarner Loshcheck()
32*517e52b6SWarner Losh{
33*517e52b6SWarner Losh	local tc=${1%.awk}; shift
34*517e52b6SWarner Losh	local in_flag out_flag err_flag
35*517e52b6SWarner Losh
36*517e52b6SWarner Losh	awk=awk
37*517e52b6SWarner Losh
38*517e52b6SWarner Losh	local out_file="${SRCDIR}/${tc}.ok"
39*517e52b6SWarner Losh	[ -f "${out_file}" ] && out_flag="-o file:${out_file}"
40*517e52b6SWarner Losh	local err_file="${SRCDIR}/${tc}.err"
41*517e52b6SWarner Losh	[ -f "${err_file}" ] && err_flag="-e file:${err_file} -s exit:2"
42*517e52b6SWarner Losh	local in_file="${SRCDIR}/${tc}.in"
43*517e52b6SWarner Losh	[ -f "${in_file}" ] && in_flag="${in_file}"
44*517e52b6SWarner Losh
45*517e52b6SWarner Losh	(cd ${SRCDIR} ; atf_check ${out_flag} ${err_flag} ${awk} -f "${tc}.awk" ${in_flag})
46*517e52b6SWarner Losh}
47*517e52b6SWarner Losh
48*517e52b6SWarner Loshadd_testcase()
49*517e52b6SWarner Losh{
50*517e52b6SWarner Losh	local tc=${1%.awk}
51*517e52b6SWarner Losh	local tc_escaped word
52*517e52b6SWarner Losh
53*517e52b6SWarner Losh	case "${tc%.*}" in
54*517e52b6SWarner Losh	*-*)
55*517e52b6SWarner Losh		local IFS="-"
56*517e52b6SWarner Losh		for word in ${tc}; do
57*517e52b6SWarner Losh			tc_escaped="${tc_escaped:+${tc_escaped}_}${word}"
58*517e52b6SWarner Losh		done
59*517e52b6SWarner Losh		;;
60*517e52b6SWarner Losh	*)
61*517e52b6SWarner Losh		tc_escaped=${tc}
62*517e52b6SWarner Losh		;;
63*517e52b6SWarner Losh	esac
64*517e52b6SWarner Losh
65*517e52b6SWarner Losh	atf_test_case ${tc_escaped}
66*517e52b6SWarner Losh	eval "${tc_escaped}_body() { check ${tc}; }"
67*517e52b6SWarner Losh	atf_add_test_case ${tc_escaped}
68*517e52b6SWarner Losh}
69*517e52b6SWarner Losh
70*517e52b6SWarner Loshatf_init_test_cases()
71*517e52b6SWarner Losh{
72*517e52b6SWarner Losh	for path in $(find -s "${SRCDIR}" -name '*.awk'); do
73*517e52b6SWarner Losh		add_testcase ${path##*/}
74*517e52b6SWarner Losh	done
75*517e52b6SWarner Losh}
76