aboutsummaryrefslogtreecommitdiff
path: root/testcase/find_command.mk
blob: 54c2c078f5e3b3c3fb1f6f41e73700e3a1093e60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# TODO(go): This test is only for ckati.

define run_find
@echo $$ '$(strip $(1))'
@echo $(sort $(shell $(1)))
endef

test1:
	mkdir testdir
	touch testdir/file1
	touch testdir/file2
	mkdir testdir/dir1
	touch testdir/dir1/file1
	touch testdir/dir1/file2
	mkdir testdir/dir2
	touch testdir/dir2/file1
	touch testdir/dir2/file2
	ln -s ../dir1/file1 testdir/dir2/link1
	ln -s ../../testdir/dir1 testdir/dir2/link2
	ln -s broken testdir/dir2/link3

test2:
	@echo no options
	$(call run_find, find testdir)
	$(call run_find, find .)
	$(call run_find, find ./)
	$(call run_find, find .///)
	$(call run_find, find )
	$(call run_find, find ./.)
	$(call run_find, find ././)
	$(call run_find, find testdir/../testdir)
	@echo print
	$(call run_find, find testdir -print)
	@echo conditiions
	$(call run_find, find testdir -name foo)
	$(call run_find, find testdir -name file1)
	$(call run_find, find testdir -name "file1")
	$(call run_find, find testdir -name "file1")
	$(call run_find, find testdir -name "*1")
	$(call run_find, find testdir -name "*1" -and -name "file*")
	$(call run_find, find testdir -name "*1" -or -name "file*")
	$(call run_find, find testdir -name "*1" -or -type f)
	$(call run_find, find testdir -name "*1" -or -not -type f)
	$(call run_find, find testdir -name "*1" -or \! -type f)
	$(call run_find, find testdir -name "*1" -or -type d)
	$(call run_find, find testdir -name "*1" -or -type l)
	$(call run_find, find testdir -name "*1" -a -type l -o -name "dir*")
	$(call run_find, find testdir -name "dir*" -o -name "*1" -a -type l)
	$(call run_find, find testdir \( -name "dir*" -o -name "*1" \) -a -type f)
	@echo cd
	$(call run_find, cd testdir && find)
	$(call run_find, cd testdir/// && find .)
	$(call run_find, cd testdir && find ../testdir)
	@echo test
	$(call run_find, test -d testdir && find testdir)
	$(call run_find, if [ -d testdir ] ; then find testdir ; fi)
	$(call run_find, if [ -d testdir ]; then find testdir; fi)
	$(call run_find, if [ -d testdir ]; then cd testdir && find .; fi)
	@echo prune
	$(call run_find, find testdir -name dir2 -prune -o -name file1)
	@echo multi
	$(call run_find, find testdir testdir)
	@echo symlink
	$(call run_find, find -L testdir -type f)
	$(call run_find, find -L testdir -type d)
	$(call run_find, find -L testdir -type l)
	$(call run_find, cd testdir; find -L . -type f)
	$(call run_find, cd testdir; find -L . -type d)
	$(call run_find, cd testdir; find -L . -type l)
	@echo maxdepth
	$(call run_find, find testdir -maxdepth 1)
	$(call run_find, find testdir -maxdepth 2)
	$(call run_find, find testdir -maxdepth 0)
	$(call run_find, find testdir -maxdepth hoge)
	$(call run_find, find testdir -maxdepth 1hoge)
	$(call run_find, find testdir -maxdepth -1)