find.tests 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. # testing "description" "command" "result" "infile" "stdin"
  40. rm -rf find.tempdir
  41. exit $FAILCOUNT