find.tests 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. # Copyright 2014 by Denys Vlasenko <vda.linux@googlemail.com>
  3. # Licensed under GPLv2, see file LICENSE in this source tree.
  4. . ./testing.sh
  5. # testing "description" "command" "result" "infile" "stdin"
  6. mkdir -p find.tempdir
  7. touch find.tempdir/testfile
  8. optional FEATURE_FIND_TYPE
  9. testing "find -type f" \
  10. "cd find.tempdir && find -type f 2>&1" \
  11. "./testfile\n" \
  12. "" ""
  13. SKIP=
  14. optional FEATURE_FIND_EXEC
  15. testing "find -exec exitcode 1" \
  16. "cd find.tempdir && find testfile -exec true {} \; 2>&1; echo \$?" \
  17. "0\n" \
  18. "" ""
  19. SKIP=
  20. optional FEATURE_FIND_EXEC_PLUS
  21. testing "find -exec exitcode 2" \
  22. "cd find.tempdir && find testfile -exec true {} + 2>&1; echo \$?" \
  23. "0\n" \
  24. "" ""
  25. SKIP=
  26. optional FEATURE_FIND_EXEC_OK
  27. testing "find -ok" \
  28. "cd find.tempdir && find testfile -ok true {} ';' 2>&1; echo \$?" \
  29. "true testfile ?0\n" \
  30. "" "y"
  31. SKIP=
  32. # Surprisingly, "-exec false ;" results in exitcode 0! "-exec false +" is different!!!
  33. optional FEATURE_FIND_EXEC
  34. testing "find -exec exitcode 3" \
  35. "cd find.tempdir && find testfile -exec false {} \; 2>&1; echo \$?" \
  36. "0\n" \
  37. "" ""
  38. SKIP=
  39. optional FEATURE_FIND_EXEC_PLUS
  40. testing "find -exec exitcode 4" \
  41. "cd find.tempdir && find testfile -exec false {} + 2>&1; echo \$?" \
  42. "1\n" \
  43. "" ""
  44. SKIP=
  45. optional FEATURE_FIND_MAXDEPTH
  46. testing "find / -maxdepth 0 -name /" \
  47. "find / -maxdepth 0 -name /" \
  48. "/\n" \
  49. "" ""
  50. testing "find // -maxdepth 0 -name /" \
  51. "find // -maxdepth 0 -name /" \
  52. "//\n" \
  53. "" ""
  54. testing "find / -maxdepth 0 -name //" \
  55. "find / -maxdepth 0 -name //" \
  56. "" \
  57. "" ""
  58. testing "find // -maxdepth 0 -name //" \
  59. "find // -maxdepth 0 -name //" \
  60. "" \
  61. "" ""
  62. SKIP=
  63. testing "find ./// -name ." \
  64. "find ./// -name ." \
  65. ".///\n" \
  66. "" ""
  67. testing "find ./// -name .///" \
  68. "find ./// -name .///" \
  69. "" \
  70. "" ""
  71. # testing "description" "command" "result" "infile" "stdin"
  72. rm -rf find.tempdir
  73. exit $FAILCOUNT