pwd (1378B)
- #!/usr/bin/env atf-sh
- # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
- atf_test_case simple
- simple_body() {
- atf_check -o "inline:${PWD}\n" ../bin/pwd
- atf_check -o "inline:$(atf_get_srcdir)\n" ../bin/pwd
- }
- atf_test_case args
- args_body() {
- atf_check -s exit:1 -e "inline:usage: pwd\n" ../bin/pwd -H
- }
- atf_test_case enoent cleanup
- enoent_body() {
- mkdir -p "$(atf_get_srcdir)/remove-me" || exit 1
- cd "$(atf_get_srcdir)/remove-me" || exit 1
- atf_check -o "inline:$(atf_get_srcdir)/remove-me\n" "$(atf_get_srcdir)/../bin/pwd"
- rm -fr "$(atf_get_srcdir)/remove-me" || exit 1
- atf_check -s exit:1 -e 'inline:getcwd: No such file or directory\n' "$(atf_get_srcdir)/../bin/pwd"
- }
- enoent_cleanup() {
- rm -fr "$(atf_get_srcdir)/remove-me"
- }
- atf_test_case devfull
- devfull_body() {
- has_glibc && atf_expect_fail "glibc ignoring write errors for puts()"
- [ "$(uname -s)" = "NetBSD" ] && atf_expect_fail "NetBSD ignoring write errors for puts()"
- [ "$(uname -s)" = "FreeBSD" ] && atf_expect_fail "FreeBSD ignoring write errors for puts()"
- atf_check -s exit:1 sh -c '../bin/pwd >/dev/full'
- }
- atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
- . ../test_functions.sh
- atf_add_test_case simple
- atf_add_test_case args
- atf_add_test_case enoent
- atf_add_test_case devfull
- }