find.tests 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. # Surprisingly, "-exec false ;" results in exitcode 0! "-exec false +" is different!!!
  27. optional FEATURE_FIND_EXEC
  28. testing "find -exec exitcode 3" \
  29. "cd find.tempdir && find testfile -exec false {} \; 2>&1; echo \$?" \
  30. "0\n" \
  31. "" ""
  32. SKIP=
  33. optional FEATURE_FIND_EXEC_PLUS
  34. testing "find -exec exitcode 4" \
  35. "cd find.tempdir && find testfile -exec false {} + 2>&1; echo \$?" \
  36. "1\n" \
  37. "" ""
  38. SKIP=
  39. optional FEATURE_FIND_MAXDEPTH
  40. testing "find / -maxdepth 0 -name /" \
  41. "find / -maxdepth 0 -name /" \
  42. "/\n" \
  43. "" ""
  44. testing "find // -maxdepth 0 -name /" \
  45. "find // -maxdepth 0 -name /" \
  46. "//\n" \
  47. "" ""
  48. testing "find / -maxdepth 0 -name //" \
  49. "find / -maxdepth 0 -name //" \
  50. "" \
  51. "" ""
  52. testing "find // -maxdepth 0 -name //" \
  53. "find // -maxdepth 0 -name //" \
  54. "" \
  55. "" ""
  56. SKIP=
  57. testing "find ./// -name ." \
  58. "find ./// -name ." \
  59. ".///\n" \
  60. "" ""
  61. testing "find ./// -name .///" \
  62. "find ./// -name .///" \
  63. "" \
  64. "" ""
  65. # testing "description" "command" "result" "infile" "stdin"
  66. rm -rf find.tempdir
  67. exit $FAILCOUNT