logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

errno (1415B)


  1. #!/usr/bin/env atf-sh
  2. # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
  4. atf_test_case simple
  5. simple_body() {
  6. atf_check -o "inline:Operation not permitted\n" ../bin/errno 1
  7. }
  8. atf_test_case noargs
  9. noargs_body() {
  10. atf_check -s exit:1 -o "inline:usage: errno <number>\n" ../bin/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 '../bin/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" ../bin/errno -1
  23. elif has_musl; then
  24. atf_check -s exit:0 -o "inline:No error information\n" ../bin/errno -1
  25. else
  26. atf_check -s exit:1 -e "inline:errno: strerror: Invalid argument\n" ../bin/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 ../bin/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. }