OSDN Git Service

am 540923b2: am 2738b318: Merge remote-tracking branch \'toybox/master\' into HEAD
[android-x86/external-toybox.git] / tests / find.test
1 #!/bin/bash
2
3 [ -f testing.sh ] && . testing.sh
4
5 mkdir dir
6 cd dir
7 touch file
8 mkfifo fifo
9 ln -s fifo link
10 cd ..
11
12 #testing "name" "command" "result" "infile" "stdin"
13
14 # Testing operators
15
16 testing "find -type l -a -type d -o -type p" \
17         "find dir -type l -a -type d -o -type p" "dir/fifo\n" "" ""
18 testing "find -type l -type d -o -type p" "find dir -type l -type d -o -type p" \
19         "dir/fifo\n" "" ""
20 testing "find -type l -o -type d -a -type p" \
21         "find dir -type l -o -type d -a -type p" "dir/link\n" "" ""
22 testing "find -type l -o -type d -type p" "find dir -type l -o -type d -type p" \
23         "dir/link\n" "" ""
24 testing "find -type l ( -type d -o -type l )" \
25         "find dir -type l \( -type d -o -type l \)" "dir/link\n" "" ""
26 testing "find extra parantheses" \
27         "find dir \( \( -type l \) \( -type d -o \( \( -type l \) \) \) \)" \
28         "dir/link\n" "" ""
29 testing "find ( -type p -o -type d ) -type p" \
30         "find dir \( -type p -o -type d \) -type p" "dir/fifo\n" "" ""
31 testing "find -type l -o -type d -type p -o -type f" \
32         "find dir -type l -o -type d -type p -o -type f | sort" \
33         "dir/file\ndir/link\n" "" ""
34
35 # Testing short-circuit evaluations
36
37 testing "find -type f -a -print" \
38         "find dir -type f -a -print" "dir/file\n" "" ""
39 testing "find -print -o -print" \
40         "find dir -type f -a \( -print -o -print \)" "dir/file\n" "" ""
41
42 rm -rf dir