errno (1394B)
- #!/usr/bin/env atf-sh
- # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- atf_test_case simple
- simple_body() {
- atf_check -o "inline:Operation not permitted\n" ../cmd/errno 1
- }
- atf_test_case noargs
- noargs_body() {
- atf_check -s exit:1 -o "inline:usage: errno <number>\n" ../cmd/errno
- }
- 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 '../cmd/errno 1 >/dev/full'
- }
- atf_test_case einval
- einval_body() {
- if has_glibc; then
- atf_check -s exit:0 -o "inline:Unknown error -1\n" ../cmd/errno -1
- elif has_musl; then
- atf_check -s exit:0 -o "inline:No error information\n" ../cmd/errno -1
- else
- atf_check -s exit:1 -e "inline:errno: strerror: Invalid argument\n" ../cmd/errno -1
- fi
- }
- atf_test_case erange
- erange_body() {
- # 36893488147419103232 = 2^65
- atf_check -s 'exit:1' -e not-empty ../cmd/errno 36893488147419103232
- }
- atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
- . ../test_functions.sh
- atf_add_test_case simple
- atf_add_test_case noargs
- atf_add_test_case devfull
- atf_add_test_case einval
- atf_add_test_case erange
- }