diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2025-12-06 13:48:32 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2026-02-13 12:40:57 +0000 |
| commit | 394201ce5b4e2f84f1e39a7ce8bdc3f5a5ef8390 (patch) | |
| tree | f368cf84429c0f9dc69503c6a5a13e1794537be5 | |
| parent | 1e2eea55c4559544b68c99e95641097983230611 (diff) | |
tests: Simplify libarchive tests
The ATF tests work by first running the test program with an invalid
flag, which causes it to print an error message, a summary of options,
and a list of available test cases. Switch to the new -l option which
simply prints the list, and simplify the awk script used to parse the
output. No functional change.
MFC after: 1 week
| -rwxr-xr-x | lib/libarchive/tests/functional_test.sh | 2 | ||||
| -rwxr-xr-x | usr.bin/bsdcat/tests/functional_test.sh | 2 | ||||
| -rwxr-xr-x | usr.bin/cpio/tests/functional_test.sh | 2 | ||||
| -rwxr-xr-x | usr.bin/tar/tests/functional_test.sh | 4 | ||||
| -rwxr-xr-x | usr.bin/unzip/tests/functional_test.sh | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/lib/libarchive/tests/functional_test.sh b/lib/libarchive/tests/functional_test.sh index 191eae65f4dc..db3845b5e6f7 100755 --- a/lib/libarchive/tests/functional_test.sh +++ b/lib/libarchive/tests/functional_test.sh @@ -40,7 +40,7 @@ atf_init_test_cases() # Redirect stderr to stdout for the usage message because if you don't # kyua list/kyua test will break: # https://github.com/jmmv/kyua/issues/149 - testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }') + testcases=$(${TESTER} -l 2>&1 | awk '/^ [0-9]+: / { print $2 }') for testcase in ${testcases}; do atf_test_case ${testcase} eval "${testcase}_body() { check ${testcase}; }" diff --git a/usr.bin/bsdcat/tests/functional_test.sh b/usr.bin/bsdcat/tests/functional_test.sh index efed232374e2..27bf51298bb8 100755 --- a/usr.bin/bsdcat/tests/functional_test.sh +++ b/usr.bin/bsdcat/tests/functional_test.sh @@ -46,7 +46,7 @@ atf_init_test_cases() # Redirect stderr to stdout for the usage message because if you don't # kyua list/kyua test will break: # https://github.com/jmmv/kyua/issues/149 - testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }') + testcases=$(${TESTER} -l 2>&1 | awk '/^ [0-9]+: / { print $2 }') for testcase in ${testcases}; do atf_test_case ${testcase} eval "${testcase}_body() { check ${testcase}; }" diff --git a/usr.bin/cpio/tests/functional_test.sh b/usr.bin/cpio/tests/functional_test.sh index a915cc91faea..6bc58e5236ae 100755 --- a/usr.bin/cpio/tests/functional_test.sh +++ b/usr.bin/cpio/tests/functional_test.sh @@ -46,7 +46,7 @@ atf_init_test_cases() # Redirect stderr to stdout for the usage message because if you don't # kyua list/kyua test will break: # https://github.com/jmmv/kyua/issues/149 - testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }') + testcases=$(${TESTER} -l 2>&1 | awk '/^ [0-9]+: / { print $2 }') for testcase in ${testcases}; do atf_test_case ${testcase} eval "${testcase}_body() { check ${testcase}; }" diff --git a/usr.bin/tar/tests/functional_test.sh b/usr.bin/tar/tests/functional_test.sh index 39a73abd0a79..11f3cb6dd122 100755 --- a/usr.bin/tar/tests/functional_test.sh +++ b/usr.bin/tar/tests/functional_test.sh @@ -25,9 +25,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -export BSDTAR=$(which tar) SRCDIR=$(atf_get_srcdir) TESTER="${SRCDIR}/bsdtar_test" +export BSDTAR=$(which tar) check() { @@ -41,7 +41,7 @@ atf_init_test_cases() # Redirect stderr to stdout for the usage message because if you don't # kyua list/kyua test will break: # https://github.com/jmmv/kyua/issues/149 - testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }') + testcases=$(${TESTER} -l 2>&1 | awk '/^ [0-9]+: / { print $2 }') for testcase in ${testcases}; do atf_test_case ${testcase} eval "${testcase}_body() { check ${testcase}; }" diff --git a/usr.bin/unzip/tests/functional_test.sh b/usr.bin/unzip/tests/functional_test.sh index e668453d8882..c6b25cfc2e7e 100755 --- a/usr.bin/unzip/tests/functional_test.sh +++ b/usr.bin/unzip/tests/functional_test.sh @@ -46,7 +46,7 @@ atf_init_test_cases() # Redirect stderr to stdout for the usage message because if you don't # kyua list/kyua test will break: # https://github.com/jmmv/kyua/issues/149 - testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }') + testcases=$(${TESTER} -l 2>&1 | awk '/^ [0-9]+: / { print $2 }') for testcase in ${testcases}; do atf_test_case ${testcase} eval "${testcase}_body() { check ${testcase}; }" |
