logo

utils

Old programs, got split in utils-std and utils-extra git clone https://anongit.hacktivis.me/git/utils.git/

errno (1394B)


  1. #!/usr/bin/env atf-sh
  2. # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. atf_test_case simple
  5. simple_body() {
  6. atf_check -o "inline:Operation not permitted\n" ../cmd/errno 1
  7. }
  8. atf_test_case noargs
  9. noargs_body() {
  10. atf_check -s exit:1 -o "inline:usage: errno <number>\n" ../cmd/errno
  11. }
  12. atf_test_case devfull
  13. devfull_body() {
  14. has_glibc && atf_expect_fail "glibc ignoring write errors for puts()"
  15. [ "$(uname -s)" = "NetBSD" ] && atf_expect_fail "NetBSD ignoring write errors for puts()"
  16. [ "$(uname -s)" = "FreeBSD" ] && atf_expect_fail "FreeBSD ignoring write errors for puts()"
  17. atf_check -s exit:1 sh -c '../cmd/errno 1 >/dev/full'
  18. }
  19. atf_test_case einval
  20. einval_body() {
  21. if has_glibc; then
  22. atf_check -s exit:0 -o "inline:Unknown error -1\n" ../cmd/errno -1
  23. elif has_musl; then
  24. atf_check -s exit:0 -o "inline:No error information\n" ../cmd/errno -1
  25. else
  26. atf_check -s exit:1 -e "inline:errno: strerror: Invalid argument\n" ../cmd/errno -1
  27. fi
  28. }
  29. atf_test_case erange
  30. erange_body() {
  31. # 36893488147419103232 = 2^65
  32. atf_check -s 'exit:1' -e not-empty ../cmd/errno 36893488147419103232
  33. }
  34. atf_init_test_cases() {
  35. cd "$(atf_get_srcdir)" || exit 1
  36. . ../test_functions.sh
  37. atf_add_test_case simple
  38. atf_add_test_case noargs
  39. atf_add_test_case devfull
  40. atf_add_test_case einval
  41. atf_add_test_case erange
  42. }