logo

utils-std

Collection of commonly available Unix tools
commit: 58262feec89e4734b14592149a302fb21b62d01e
parent 971640e9e61490d32b40a88fff61502ce75270e7
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 14 Mar 2024 02:21:30 +0100

test-cmd/chmod: new

Diffstat:

Mtest-cmd/Kyuafile1+
Atest-cmd/chmod28++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile @@ -8,6 +8,7 @@ test_suite("utils-std commands") atf_test_program{name="base64", timeout=1} atf_test_program{name="basename", timeout=1} atf_test_program{name="cat", timeout=1} +atf_test_program{name="chmod", timeout=1} atf_test_program{name="date", timeout=1} atf_test_program{name="df", timeout=1} atf_test_program{name="dirname", timeout=1} diff --git a/test-cmd/chmod b/test-cmd/chmod @@ -0,0 +1,28 @@ +#!/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 '0888': syntax error, got invalid character\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 +}