logo

utils-std

Collection of commonly available Unix tools

pwd (1336B)


  1. #!/usr/bin/env atf-sh
  2. # SPDX-FileCopyrightText: 2017 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:${PWD}\n" ../cmd/pwd
  7. atf_check -o "inline:$(atf_get_srcdir)\n" ../cmd/pwd
  8. }
  9. atf_test_case args
  10. args_body() {
  11. atf_check -s exit:1 -e "inline:usage: pwd\n" ../cmd/pwd -H
  12. }
  13. atf_test_case enoent cleanup
  14. enoent_body() {
  15. mkdir -p "$(atf_get_srcdir)/remove-me" || exit 1
  16. cd "$(atf_get_srcdir)/remove-me" || exit 1
  17. atf_check -o "inline:$(atf_get_srcdir)/remove-me\n" "$(atf_get_srcdir)/../cmd/pwd"
  18. rm -fr "$(atf_get_srcdir)/remove-me" || exit 1
  19. atf_check -s exit:1 -e 'inline:pwd: getcwd: No such file or directory\n' "$(atf_get_srcdir)/../cmd/pwd"
  20. }
  21. enoent_cleanup() {
  22. rm -fr "$(atf_get_srcdir)/remove-me"
  23. }
  24. atf_test_case devfull
  25. devfull_body() {
  26. has_glibc && atf_skip "glibc ignoring write errors for puts()"
  27. [ "$(uname -s)" = "NetBSD" ] && atf_skip "NetBSD ignoring write errors for puts()"
  28. [ "$(uname -s)" = "FreeBSD" ] && atf_skip "FreeBSD ignoring write errors for puts()"
  29. atf_check -s exit:1 sh -c '../cmd/pwd >/dev/full'
  30. }
  31. atf_init_test_cases() {
  32. cd "$(atf_get_srcdir)" || exit 1
  33. . ../test_functions.sh
  34. atf_add_test_case simple
  35. atf_add_test_case args
  36. atf_add_test_case enoent
  37. atf_add_test_case devfull
  38. }