commit: 381010df2fff2320e885cb6933b80d7a8beb5797
parent b23f60c894d6b884b942b931546de334952e6ea5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 13 Jun 2024 11:58:01 +0200
test-cmd/basename*: Change from ATF to tap.sh
Diffstat:
3 files changed, 34 insertions(+), 81 deletions(-)
diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile
@@ -8,7 +8,6 @@ basedir = fs.dirname(fs.dirname(current_kyuafile()))
-- 9,$|LC_ALL=C.UTF-8 sort
atf_test_program{name="base64", required_files=basedir.."/cmd/base64", timeout=1}
-atf_test_program{name="basename", required_files=basedir.."/cmd/basename", timeout=1}
atf_test_program{name="cat", required_files=basedir.."/cmd/cat", timeout=1}
atf_test_program{name="chmod", required_files=basedir.."/cmd/chmod", timeout=1}
atf_test_program{name="date", required_files=basedir.."/cmd/date", timeout=1}
@@ -28,6 +27,7 @@ atf_test_program{name="true", required_files=basedir.."/cmd/true", timeout=1}
atf_test_program{name="tty", required_files=basedir.."/cmd/tty", timeout=1}
atf_test_program{name="unlink", required_files=basedir.."/cmd/unlink", timeout=1}
tap_test_program{name="arch.sh", required_files=basedir.."/cmd/arch", timeout=1}
+tap_test_program{name="basename.sh", required_files=basedir.."/cmd/basename", timeout=1}
tap_test_program{name="seq.sh", required_files=basedir.."/cmd/seq", timeout=1}
tap_test_program{name="test.sh", required_files=basedir.."/cmd/test", timeout=2}
tap_test_program{name="uname.sh", required_files=basedir.."/cmd/uname", timeout=1}
diff --git a/test-cmd/basename b/test-cmd/basename
@@ -1,80 +0,0 @@
-#!/usr/bin/env atf-sh
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-
-
-atf_test_case noargs
-noargs_body() {
- atf_check -o "inline:.\n" ../cmd/basename
-}
-
-atf_test_case one_slash
-one_slash_body() {
- atf_check -o "inline:bin\n" ../cmd/basename "/usr/bin"
-}
-
-atf_test_case two_slash
-two_slash_body() {
- atf_check -o "inline:bin\n" ../cmd/basename "/usr//bin"
-}
-
-atf_test_case two_dash
-two_dash_body() {
- atf_check -o "inline:bin\n" ../cmd/basename -- "/usr//bin"
-}
-
-atf_test_case testopt
-testopt_body() {
- atf_check -o "inline:bin\n" ../cmd/basename "/usr//bin-test" "-test"
-}
-
-atf_test_case usage
-usage_body() {
- atf_check -s exit:1 -e "inline:usage: basename string [suffix]\n" ../cmd/basename 1 2 3
-}
-
-atf_test_case devfull
-devfull_body() {
- has_glibc && atf_skip "glibc ignoring write errors for puts()"
- [ "$(uname -s)" = "NetBSD" ] && atf_skip "NetBSD ignoring write errors for puts()"
- [ "$(uname -s)" = "FreeBSD" ] && atf_skip "FreeBSD ignoring write errors for puts()"
-
- atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename >/dev/full'
- atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename "/usr/bin" >/dev/full'
- atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename "/usr//bin-test" "-test" >/dev/full'
-}
-
-atf_test_case nullarg
-nullarg_body() {
- atf_check -e "inline:.\n" ../cmd/basename "$(printf '\x00')"
- atf_check -e "inline:bin\n" ../cmd/basename "/usr/bin" "$(printf '\x00')"
-}
-
-atf_test_case doubledash
-doubledash_body() {
- atf_check -o 'inline:-\n' -- ../cmd/basename '-'
- atf_check -o 'inline:.\n' -- ../cmd/basename '--'
- atf_check -o 'inline:--\n' -- ../cmd/basename --a a
- atf_check -o 'inline:---\n' -- ../cmd/basename '---'
-}
-
-atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
-
- . ../test_functions.sh
-
- atf_add_test_case noargs
- atf_add_test_case one_slash
- atf_add_test_case two_slash
- atf_add_test_case two_dash
- atf_add_test_case testopt
- atf_add_test_case usage
-
- # puts in glibc doesn't returns -1 on failure
- atf_add_test_case devfull
-
- # Broken behavior in ATF, might be caused by stripping out \x00
- #atf_add_test_case nullarg
-
- atf_add_test_case doubledash
-}
diff --git a/test-cmd/basename.sh b/test-cmd/basename.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+target="$(dirname "$0")/../cmd/basename"
+plans=9
+. "$(dirname "$0")/tap.sh"
+
+t 'no args' '' $'.\n'
+t '/usr/bin' '/usr/bin' $'bin\n'
+t '/usr//bin' '/usr//bin' $'bin\n'
+t '-- /usr//bin' '-- /usr//bin' $'bin\n'
+t 'suffix' '/usr//bin-test -test' $'bin\n'
+t '-' '-' $'-\n'
+t '--' '--' $'.\n'
+t '---' '---' $'---\n'
+t '--a a' '--a a' $'--\n'
+
+#atf_test_case usage
+#usage_body() {
+# atf_check -s exit:1 -e "inline:usage: basename string [suffix]\n" ../cmd/basename 1 2 3
+#}
+
+#atf_test_case devfull
+#devfull_body() {
+# has_glibc && atf_skip "glibc ignoring write errors for puts()"
+# [ "$(uname -s)" = "NetBSD" ] && atf_skip "NetBSD ignoring write errors for puts()"
+# [ "$(uname -s)" = "FreeBSD" ] && atf_skip "FreeBSD ignoring write errors for puts()"
+#
+# atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename >/dev/full'
+# atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename "/usr/bin" >/dev/full'
+# atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename "/usr//bin-test" "-test" >/dev/full'
+#}