git: 05f0dcd80d6a - stable/15 - tests: Simplify libarchive tests

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Tue, 17 Feb 2026 23:57:57 UTC
The branch stable/15 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=05f0dcd80d6a5203c061825ba8435a4732754930

commit 05f0dcd80d6a5203c061825ba8435a4732754930
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-12-06 13:48:32 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-02-17 23:11:48 +0000

    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
    
    (cherry picked from commit 394201ce5b4e2f84f1e39a7ce8bdc3f5a5ef8390)
---
 lib/libarchive/tests/functional_test.sh | 2 +-
 usr.bin/bsdcat/tests/functional_test.sh | 2 +-
 usr.bin/cpio/tests/functional_test.sh   | 2 +-
 usr.bin/tar/tests/functional_test.sh    | 4 ++--
 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}; }"