env (2115B)
- #!/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 noargs
- noargs_body() {
- [ "${LD_PRELOAD}" = "libsandbox.so" ] && atf_expect_fail "sandbox (gentoo) interferes with the environment"
- atf_check -o "inline:FOO=BAR\n" env -i FOO=BAR ../bin/env
- }
- atf_test_case badarg
- badarg_body() {
- atf_check -s not-exit:0 -e "inline:Error: Unrecognised option: '-f'\nenv [-i] [-u key] [key=value ...] [command [args]]\n" ../bin/env -f
- }
- atf_test_case iflag
- iflag_body() {
- [ "${LD_PRELOAD}" = "libsandbox.so" ] && atf_expect_fail "sandbox (gentoo) interferes with the environment"
- atf_check -o "inline:FOO=BAR\n" ../bin/env -i FOO=BAR ../bin/env
- atf_check -o "inline:FOO=BAR\n" ../bin/env -i FOO=BAR
- atf_check -o "not-inline:FOO=BAR\n" ../bin/env FOO=BAR ../bin/env
- atf_check -o "not-inline:FOO=BAR\n" ../bin/env FOO=BAR
- }
- atf_test_case uflag
- uflag_body() {
- [ "${LD_PRELOAD}" = "libsandbox.so" ] && atf_expect_fail "sandbox (gentoo) interferes with the environment"
- atf_check -o "inline:FOO=BAR\n" ../bin/env -i FOO=BAR BAR=FOO ../bin/env -u BAR
- atf_check -s not-exit:0 -e "inline:Error: Missing operand for option: '-u'\nenv [-i] [-u key] [key=value ...] [command [args]]\n" ../bin/env -u
- }
- atf_test_case devfull
- devfull_body() {
- [ "$(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 -e 'inline:env: puts: No space left on device\n' sh -c '../bin/env >/dev/full'
- }
- atf_test_case noutil
- noutil_body() {
- atf_check -s exit:127 -e 'inline:env: execve: No such file or directory\n' ../bin/env /var/empty/e/no/ent
- }
- atf_test_case false
- false_body() {
- atf_check -s exit:1 ../bin/env false
- }
- atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
- atf_add_test_case noargs
- atf_add_test_case badarg
- atf_add_test_case iflag
- atf_add_test_case uflag
- atf_add_test_case devfull
- atf_add_test_case noutil
- atf_add_test_case false
- }