3 # The common objpfx, used to find libraries and the dynamic loader.
6 # We expect one parameter which is the test program. This must understand
8 # --phys use the FTW_PHYS flag
9 # --chdir use the FTW_CHDIR and print the current directory in the
11 # --depth use the FTW_DEPTH flag
15 # First create our scenario:
16 tmp
=`echo ${TMPDIR:-/tmp} | sed 's|\(.\)/*$|\1|'`
19 [ -f ${objpfx}elf
/ld.so
] && ldso
=${objpfx}elf
/ld.so
21 trap 'chmod -R a+x $tmpdir; rm -fr $tmpdir $testout' 1 2 3 15
23 if test -d $tmpdir; then
31 mkdir
$tmpdir/foo
/lvl1
32 echo > $tmpdir/foo
/lvl
1/file@
1
33 mkdir
$tmpdir/foo
/lvl
1/lvl2
34 echo > $tmpdir/foo
/lvl
1/lvl
2/file@
2
35 mkdir
$tmpdir/foo
/lvl
1/lvl
2/lvl3
36 echo > $tmpdir/foo
/lvl
1/lvl
2/lvl
3/file@
3
37 ln -s $tmpdir $tmpdir/foo
/lvl
1/lvl
2/lvl
3/link@
3
38 ln -s $tmpdir/foo
/lvl
1/lvl2
$tmpdir/foo
/lvl
1/lvl
2/link@
2
39 ln -s $tmpdir/foo
/lvl
1/lvl
2/lvl
3/lvl4
$tmpdir/foo
/lvl
1/link@
1
41 chmod a-x
,a
+r
$tmpdir/bar
43 testout
=${TMPDIR:-/tmp}/ftwtest.out
45 LD_LIBRARY_PATH
=$objpfx $ldso $testprogram $tmpdir |
48 cat <<EOF | cmp $testout - || exit 1
49 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
50 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
51 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
52 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
53 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
54 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
55 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
56 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
57 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
58 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
59 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
60 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
64 LD_LIBRARY_PATH
=$objpfx $ldso $testprogram --depth $tmpdir |
67 cat <<EOF | cmp $testout - || exit 1
68 base = "$tmp/", file = "ftwtest.d", flag = FTW_DP, level = 0
69 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_DP, level = 1
70 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
71 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_DP, level = 1
72 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
73 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_DP, level = 2
74 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
75 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
76 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_DP, level = 3
77 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
78 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_DP, level = 4
79 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
83 LD_LIBRARY_PATH
=$objpfx $ldso $testprogram --phys $tmpdir |
86 cat <<EOF | cmp $testout - || exit 1
87 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
88 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
89 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
90 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
91 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
92 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
93 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
94 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SL, level = 3
95 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
96 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
97 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "link@2", flag = FTW_SL, level = 4
98 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
99 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
100 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "link@3", flag = FTW_SL, level = 5
104 # For the next test everything must be readable.
107 LD_LIBRARY_PATH
=$objpfx $ldso $testprogram --chdir $tmpdir |
110 # perhaps $tmp involves some symlinks...
111 tmpreal
=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd`
113 cat <<EOF | cmp $testout - || exit 1
114 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
115 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
116 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, cwd = $tmpreal/ftwtest.d, level = 1
117 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
118 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_F, cwd = $tmpreal/ftwtest.d/bar, level = 2
119 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo, level = 2
120 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
121 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
122 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
123 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
124 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
125 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2/lvl3, level = 5