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