logo

utils-std

Collection of commonly available Unix tools
commit: 8d899696bd5abd98ad3c1bfcc718bfada8105f7f
parent 73468d68904545b8a2388f89d56f6e4acd41769b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 31 Mar 2024 09:05:55 +0200

test-cmd/logname: Skip on glibc due to utmp usage

Diffstat:

Mtest-cmd/Kyuafile1+
Atest-cmd/logname26++++++++++++++++++++++++++
Dtest-cmd/logname.t9---------
3 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile @@ -19,6 +19,7 @@ atf_test_program{name="env", required_files=basedir.."/cmd/env", timeout=1} atf_test_program{name="false", required_files=basedir.."/cmd/false", timeout=1} atf_test_program{name="id", required_files=basedir.."/cmd/id", timeout=1} atf_test_program{name="link", required_files=basedir.."/cmd/link", timeout=1} +atf_test_program{name="logname", required_files=basedir.."/cmd/logname", timeout=1} atf_test_program{name="pwd", required_files=basedir.."/cmd/pwd", timeout=1} atf_test_program{name="seq", required_files=basedir.."/cmd/seq", timeout=1} atf_test_program{name="strings", required_files=basedir.."/cmd/strings", timeout=1} diff --git a/test-cmd/logname b/test-cmd/logname @@ -0,0 +1,26 @@ +#!/usr/bin/env atf-sh +# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +# SPDX-License-Identifier: MPL-2.0 + +atf_test_case id +id_body() { + # glibc uses utmp, of all the thingsā€¦ + has_glibc && atf_skip + + atf_check -o "inline:$(id -un)\n" ../cmd/logname +} + +atf_test_case environ +environ_body() { + atf_check -o "inline:${LOGNAME}\n" ../cmd/logname +} + +atf_init_test_cases() { + cd "$(atf_get_srcdir)" || exit 1 + + . ../test_functions.sh + + atf_add_test_case id + + test -n "${LOGNAME}" && atf_add_test_case environ +} diff --git a/test-cmd/logname.t b/test-cmd/logname.t @@ -1,9 +0,0 @@ -#!/usr/bin/env cram -# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> -# SPDX-License-Identifier: MPL-2.0 - - $ export PATH="$TESTDIR/../cmd:$PATH" - - $ test "$(command -v logname)" = "$TESTDIR/../cmd/logname" - - $ test "$(id -un)" = "$(logname)"