xref: /freebsd/lib/libregex/tests/libregex_test.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1b37f6c98SKyle Evans#
2*4d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause
3e12ff891SKyle Evans#
4b37f6c98SKyle Evans# Copyright (c) 2017 Kyle Evans <kevans@FreeBSD.org>
5b37f6c98SKyle Evans#
6b37f6c98SKyle Evans# Redistribution and use in source and binary forms, with or without
7b37f6c98SKyle Evans# modification, are permitted provided that the following conditions
8b37f6c98SKyle Evans# are met:
9b37f6c98SKyle Evans# 1. Redistributions of source code must retain the above copyright
10b37f6c98SKyle Evans#    notice, this list of conditions and the following disclaimer.
11b37f6c98SKyle Evans# 2. Redistributions in binary form must reproduce the above copyright
12b37f6c98SKyle Evans#    notice, this list of conditions and the following disclaimer in the
13b37f6c98SKyle Evans#    documentation and/or other materials provided with the distribution.
14b37f6c98SKyle Evans#
15b37f6c98SKyle Evans# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16b37f6c98SKyle Evans# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17b37f6c98SKyle Evans# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18b37f6c98SKyle Evans# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19b37f6c98SKyle Evans# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20b37f6c98SKyle Evans# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21b37f6c98SKyle Evans# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22b37f6c98SKyle Evans# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23b37f6c98SKyle Evans# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24b37f6c98SKyle Evans# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25b37f6c98SKyle Evans# POSSIBILITY OF SUCH DAMAGE.
26b37f6c98SKyle Evans#
27b37f6c98SKyle Evans
28b37f6c98SKyle Evanscheck()
29b37f6c98SKyle Evans{
30b37f6c98SKyle Evans	local dataname="${1}"; shift
31b37f6c98SKyle Evans
32b37f6c98SKyle Evans	prog="$(atf_get_srcdir)/h_regex"
33b37f6c98SKyle Evans	data="$(atf_get_srcdir)/data/${dataname}.in"
34b37f6c98SKyle Evans
35b37f6c98SKyle Evans	atf_check -x "${prog} <${data}"
36b37f6c98SKyle Evans	atf_check -x "${prog} -el <${data}"
37b37f6c98SKyle Evans	atf_check -x "${prog} -er <${data}"
38b37f6c98SKyle Evans}
39b37f6c98SKyle Evans
40b37f6c98SKyle Evanscreate_tc()
41b37f6c98SKyle Evans{
42b37f6c98SKyle Evans	local name="${1}"; shift
43b37f6c98SKyle Evans	local descr="${1}"; shift
44b37f6c98SKyle Evans
45b37f6c98SKyle Evans	atf_test_case "${name}"
46b37f6c98SKyle Evans	eval "${name}_head() { atf_set 'descr' '${descr}'; }"
47b37f6c98SKyle Evans	eval "${name}_body() { check '${name}'; }"
48b37f6c98SKyle Evans
49b37f6c98SKyle Evans	atf_add_test_case "${name}"
50b37f6c98SKyle Evans}
51b37f6c98SKyle Evans
52b37f6c98SKyle Evansatf_init_test_cases()
53b37f6c98SKyle Evans{
54b37f6c98SKyle Evans	create_tc gnuext "Check GNU extension functionality"
55b37f6c98SKyle Evans}
56