tty (1147B)
- #!/usr/bin/env atf-sh
- # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- atf_test_case basic
- basic_body() {
- tty >/dev/null || atf_expect_fail "test environment not in a tty"
- atf_check -o 'not-inline:not a tty\n' ../cmd/tty
- }
- atf_test_case in_devnull
- in_devnull_body() {
- atf_check -s 'exit:1' -o 'inline:not a tty\n' ../cmd/tty </dev/null
- }
- atf_test_case out_devnull
- out_devnull_body() {
- tty >/dev/null || atf_expect_fail "test environment not in a tty"
- atf_check -o 'not-inline:not a tty\n' sh -c '../cmd/tty >/dev/null'
- }
- atf_test_case out_devfull
- out_devfull_body() {
- has_glibc && atf_skip "glibc ignoring write errors for puts()"
- [ "$(uname -s)" = "NetBSD" ] && atf_skip "NetBSD ignoring write errors for puts()"
- [ "$(uname -s)" = "FreeBSD" ] && atf_skip "FreeBSD ignoring write errors for puts()"
- atf_check -s "exit:2" sh -c '../cmd/tty >/dev/full'
- }
- atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
- . ../test_functions.sh
- atf_add_test_case basic
- atf_add_test_case in_devnull
- atf_add_test_case out_devnull
- atf_add_test_case out_devfull
- }