xref: /freebsd/lib/libarchive/tests/functional_test.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1*59e2ff55SEnji Cooper#
2*59e2ff55SEnji Cooper# Copyright 2015 EMC Corp.
3*59e2ff55SEnji Cooper# All rights reserved.
4*59e2ff55SEnji Cooper#
5*59e2ff55SEnji Cooper# Redistribution and use in source and binary forms, with or without
6*59e2ff55SEnji Cooper# modification, are permitted provided that the following conditions are
7*59e2ff55SEnji Cooper# met:
8*59e2ff55SEnji Cooper#
9*59e2ff55SEnji Cooper# * Redistributions of source code must retain the above copyright
10*59e2ff55SEnji Cooper#   notice, this list of conditions and the following disclaimer.
11*59e2ff55SEnji Cooper# * Redistributions in binary form must reproduce the above copyright
12*59e2ff55SEnji Cooper#   notice, this list of conditions and the following disclaimer in the
13*59e2ff55SEnji Cooper#   documentation and/or other materials provided with the distribution.
14*59e2ff55SEnji Cooper#
15*59e2ff55SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16*59e2ff55SEnji Cooper# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17*59e2ff55SEnji Cooper# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18*59e2ff55SEnji Cooper# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19*59e2ff55SEnji Cooper# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20*59e2ff55SEnji Cooper# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21*59e2ff55SEnji Cooper# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22*59e2ff55SEnji Cooper# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23*59e2ff55SEnji Cooper# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24*59e2ff55SEnji Cooper# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25*59e2ff55SEnji Cooper# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*59e2ff55SEnji Cooper#
27*59e2ff55SEnji Cooper
28*59e2ff55SEnji CooperSRCDIR=$(atf_get_srcdir)
29*59e2ff55SEnji CooperTESTER="${SRCDIR}/libarchive_test"
30*59e2ff55SEnji Cooper
31*59e2ff55SEnji Coopercheck()
32*59e2ff55SEnji Cooper{
33*59e2ff55SEnji Cooper	local testcase=${1}; shift
34*59e2ff55SEnji Cooper
35*59e2ff55SEnji Cooper	atf_check -o ignore -s exit:0 ${TESTER} -d -r "${SRCDIR}" -v "${testcase}"
36*59e2ff55SEnji Cooper}
37*59e2ff55SEnji Cooper
38*59e2ff55SEnji Cooperatf_init_test_cases()
39*59e2ff55SEnji Cooper{
40*59e2ff55SEnji Cooper	# Redirect stderr to stdout for the usage message because if you don't
41*59e2ff55SEnji Cooper	# kyua list/kyua test will break:
42*59e2ff55SEnji Cooper	# https://github.com/jmmv/kyua/issues/149
43*59e2ff55SEnji Cooper	testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }')
44*59e2ff55SEnji Cooper	for testcase in ${testcases}; do
45*59e2ff55SEnji Cooper		atf_test_case ${testcase}
46*59e2ff55SEnji Cooper		eval "${testcase}_body() { check ${testcase}; }"
47*59e2ff55SEnji Cooper		atf_add_test_case ${testcase}
48*59e2ff55SEnji Cooper	done
49*59e2ff55SEnji Cooper}
50