1269902Sngie#
2288976Sngie# Copyright 2015 EMC Corp.
3269902Sngie# All rights reserved.
4269902Sngie#
5269902Sngie# Redistribution and use in source and binary forms, with or without
6269902Sngie# modification, are permitted provided that the following conditions are
7269902Sngie# met:
8269902Sngie#
9269902Sngie# * Redistributions of source code must retain the above copyright
10269902Sngie#   notice, this list of conditions and the following disclaimer.
11269902Sngie# * Redistributions in binary form must reproduce the above copyright
12269902Sngie#   notice, this list of conditions and the following disclaimer in the
13269902Sngie#   documentation and/or other materials provided with the distribution.
14269902Sngie#
15269902Sngie# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16269902Sngie# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17269902Sngie# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18269902Sngie# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19269902Sngie# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20269902Sngie# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21269902Sngie# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22269902Sngie# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23269902Sngie# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24269902Sngie# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25269902Sngie# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26269902Sngie#
27269902Sngie# $FreeBSD: releng/11.0/lib/libarchive/tests/functional_test.sh 288976 2015-10-07 05:20:44Z ngie $
28269902Sngie
29269902SngieSRCDIR=$(atf_get_srcdir)
30288976SngieTESTER="${SRCDIR}/libarchive_test"
31269902Sngie
32269902Sngiecheck()
33269902Sngie{
34288976Sngie	local testcase=${1}; shift
35269902Sngie
36288976Sngie	atf_check -o ignore -s exit:0 ${TESTER} -d -r "${SRCDIR}" -v "${testcase}"
37269902Sngie}
38269902Sngie
39269902Sngieatf_init_test_cases()
40269902Sngie{
41288976Sngie	# Redirect stderr to stdout for the usage message because if you don't
42288976Sngie	# kyua list/kyua test will break:
43288976Sngie	# https://github.com/jmmv/kyua/issues/149
44288976Sngie	testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }')
45288976Sngie	for testcase in ${testcases}; do
46288976Sngie		atf_test_case ${testcase}
47288976Sngie		eval "${testcase}_body() { check ${testcase}; }"
48288976Sngie		atf_add_test_case ${testcase}
49269902Sngie	done
50269902Sngie}
51