commit: d29156f63aa3173a454b2c7984e6b45c1c9b213e
parent 381010df2fff2320e885cb6933b80d7a8beb5797
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 13 Jun 2024 12:20:08 +0200
test-cmd/chmod*: Change from ATF to tap.sh
Diffstat:
3 files changed, 25 insertions(+), 29 deletions(-)
diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile
@@ -9,7 +9,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="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}
atf_test_program{name="df", required_files=basedir.."/cmd/df", timeout=1}
atf_test_program{name="dirname", required_files=basedir.."/cmd/dirname", timeout=1}
@@ -28,6 +27,7 @@ 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="chmod.sh", required_files=basedir.."/cmd/chmod", 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/chmod b/test-cmd/chmod
@@ -1,28 +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 octal cleanup
-octal_body() {
- atf_check touch "${TMPDIR}/chmod_octal"
-
- atf_check -o "inline:chmod: Permissions changed from 00644/-rw-r--r-- to 00000/---------- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 0 "${TMPDIR}/chmod_octal"
- atf_check -o "inline:chmod: Permissions already set to 00000/---------- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 00 "${TMPDIR}/chmod_octal"
- atf_check -o "inline:chmod: Permissions already set to 00000/---------- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 000 "${TMPDIR}/chmod_octal"
- atf_check -o "inline:chmod: Permissions already set to 00000/---------- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 0000 "${TMPDIR}/chmod_octal"
-
- atf_check -o "inline:chmod: Permissions changed from 00000/---------- to 00444/-r--r--r-- for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 0444 "${TMPDIR}/chmod_octal"
- atf_check -o "inline:chmod: Permissions changed from 00444/-r--r--r-- to 00777/-rwxrwxrwx for '${TMPDIR}/chmod_octal'\n" ../cmd/chmod -v 0777 "${TMPDIR}/chmod_octal"
-
- atf_check -s not-exit:0 -e "inline:chmod: Failed parsing mode '0888': contains digit outside of [0-7]\n" ../cmd/chmod -v 0888 "${TMPDIR}/chmod_octal"
-}
-octal_cleanup() {
- atf_check chmod u=rw "${TMPDIR}/chmod_octal"
- atf_check rm "${TMPDIR}/chmod_octal"
-}
-
-atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
-
- atf_add_test_case octal
-}
diff --git a/test-cmd/chmod.sh b/test-cmd/chmod.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+target="$(dirname "$0")/../cmd/chmod"
+plans=6
+. "$(dirname "$0")/tap.sh"
+
+tmpfile="${TMPDIR-/tmp}/test_chmod_$(date +%s)"
+
+touch "$tmpfile" || exit 1
+
+t '0' "-v 0 $tmpfile" "chmod: Permissions changed from 00644/-rw-r--r-- to 00000/---------- for '${tmpfile}'"$'\n'
+t '00' "-v 00 $tmpfile" "chmod: Permissions already set to 00000/---------- for '${tmpfile}'"$'\n'
+t '000' "-v 000 $tmpfile" "chmod: Permissions already set to 00000/---------- for '${tmpfile}'"$'\n'
+t '0000' "-v 0000 $tmpfile" "chmod: Permissions already set to 00000/---------- for '${tmpfile}'"$'\n'
+
+t '0444' "-v 0444 $tmpfile" "chmod: Permissions changed from 00000/---------- to 00444/-r--r--r-- for '${tmpfile}'"$'\n'
+
+t '0777' "-v 0777 $tmpfile" "chmod: Permissions changed from 00444/-r--r--r-- to 00777/-rwxrwxrwx for '${tmpfile}'"$'\n'
+
+# atf_check -s not-exit:0 -e "inline:chmod: Failed parsing mode '0888': contains digit outside of [0-7]\n" ../cmd/chmod -v 0888 "${TMPDIR}/chmod_octal"
+
+rm "$tmpfile" || exit 1