logo

utils-extra

Collection of extra tools for Unixes

mkdir (1324B)


  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 empty
  5. empty_body() {
  6. atf_check -s exit:1 -e 'inline:mkdir: missing operands\nUsage: mkdir [-p] [-m mode] [directories...]\n' ../cmd/mkdir
  7. }
  8. atf_test_case foo cleanup
  9. foo_body() {
  10. atf_check rm -fr mkdir-foo
  11. atf_check ../cmd/mkdir mkdir-foo
  12. atf_check test -d mkdir-foo
  13. }
  14. foo_cleanup() {
  15. rm -fr mkdir-foo
  16. }
  17. atf_test_case p_flag cleanup
  18. p_flag_body() {
  19. atf_check rm -fr mkdir-p_flag/1/2/3
  20. atf_check -s exit:1 -e 'inline:mkdir: No such file or directory\n' ../cmd/mkdir mkdir-p_flag/1/2/3
  21. atf_check ../cmd/mkdir -p mkdir-p_flag/1/2/3
  22. atf_check test -d mkdir-p_flag/1/2/3
  23. }
  24. p_flag_cleanup() {
  25. rm -fr mkdir-p_flag/1/2/3
  26. }
  27. atf_test_case devnull
  28. devnull_body() {
  29. atf_check -s exit:1 -e 'inline:mkdir: File exists\n' ../cmd/mkdir /dev/null
  30. atf_check -s exit:1 -e 'inline:mkdir: File exists\n' ../cmd/mkdir -p /dev/null
  31. atf_check -s exit:1 -e 'inline:mkdir: Not a directory\n' ../cmd/mkdir /dev/null/no
  32. atf_check -s exit:1 -e 'inline:mkdir: Not a directory\n' ../cmd/mkdir -p /dev/null/no
  33. }
  34. atf_init_test_cases() {
  35. cd "$(atf_get_srcdir)" || exit 1
  36. atf_add_test_case empty
  37. atf_add_test_case foo
  38. #atf_add_test_case p_flag
  39. atf_add_test_case devnull
  40. }