logo

utils-std

Collection of commonly available Unix tools

dirname (892B)


  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 noargs
  5. noargs_body() {
  6. atf_check -e "inline:usage: dirname string\n" -s exit:1 ../cmd/dirname
  7. }
  8. atf_test_case one_slash
  9. one_slash_body() {
  10. atf_check -o "inline:/usr\n" ../cmd/dirname "/usr/bin"
  11. }
  12. atf_test_case two_slash
  13. two_slash_body() {
  14. atf_check -o "inline:/usr\n" ../cmd/dirname "/usr//bin"
  15. }
  16. atf_test_case two_dash
  17. two_dash_body() {
  18. atf_check -o "inline:/usr\n" ../cmd/dirname -- "/usr//bin"
  19. }
  20. atf_test_case badarg
  21. badarg_body() {
  22. atf_check -s exit:1 -e "inline:usage: dirname string\n" ../cmd/dirname -a "/usr//bin"
  23. }
  24. atf_init_test_cases() {
  25. cd "$(atf_get_srcdir)" || exit 1
  26. atf_add_test_case noargs
  27. atf_add_test_case badarg
  28. atf_add_test_case one_slash
  29. atf_add_test_case two_slash
  30. atf_add_test_case two_dash
  31. }