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
14 # We cannot test this as root.
15 if test `id | sed "s/uid=\([0-9]*\).*/\1/"` = 0; then
19 # Since we use `sort' we must make sure to use the same locale everywhere.
25 # First create our scenario:
26 tmp
=`echo ${TMPDIR:-/tmp} | sed 's|\(.\)/*$|\1|'`
29 [ -f ${objpfx}elf
/ld.so
] && ldso
=${objpfx}elf
/ld.so
31 trap 'chmod -fR a+x $tmpdir; rm -fr $tmpdir $testout' 1 2 3 15
33 if test -d $tmpdir; then
41 mkdir
$tmpdir/foo
/lvl1
42 echo > $tmpdir/foo
/lvl
1/file@
1
43 mkdir
$tmpdir/foo
/lvl
1/lvl2
44 echo > $tmpdir/foo
/lvl
1/lvl
2/file@
2
45 mkdir
$tmpdir/foo
/lvl
1/lvl
2/lvl3
46 echo > $tmpdir/foo
/lvl
1/lvl
2/lvl
3/file@
3
47 ln -s $tmpdir $tmpdir/foo
/lvl
1/lvl
2/lvl
3/link@
3
48 ln -s $tmpdir/foo
/lvl
1/lvl2
$tmpdir/foo
/lvl
1/lvl
2/link@
2
49 ln -s $tmpdir/foo
/lvl
1/lvl
2/lvl
3/lvl4
$tmpdir/foo
/lvl
1/link@
1
51 chmod a-x
,a
+r
$tmpdir/bar
53 testout
=${TMPDIR:-/tmp}/ftwtest.out
55 LD_LIBRARY_PATH
=$objpfx $ldso $testprogram $tmpdir |
58 cat <<EOF | cmp $testout - || exit 1
59 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
60 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
61 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
62 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
63 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
64 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
65 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
66 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
67 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
68 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
69 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
70 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
74 LD_LIBRARY_PATH
=$objpfx $ldso $testprogram --depth $tmpdir |
77 cat <<EOF | cmp $testout - || exit 1
78 base = "$tmp/", file = "ftwtest.d", flag = FTW_DP, level = 0
79 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_DP, level = 1
80 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
81 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_DP, level = 1
82 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
83 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_DP, level = 2
84 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
85 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
86 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_DP, level = 3
87 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
88 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_DP, level = 4
89 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
93 LD_LIBRARY_PATH
=$objpfx $ldso $testprogram --phys $tmpdir |
96 cat <<EOF | cmp $testout - || exit 1
97 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
98 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
99 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
100 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
101 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
102 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
103 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
104 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SL, level = 3
105 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
106 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
107 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "link@2", flag = FTW_SL, level = 4
108 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
109 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
110 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "link@3", flag = FTW_SL, level = 5
114 # For the next test everything must be readable.
115 chmod -fR a
+x
$tmpdir
117 LD_LIBRARY_PATH
=$objpfx $ldso $testprogram --chdir $tmpdir |
120 # perhaps $tmp involves some symlinks...
121 tmpreal
=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd`
123 cat <<EOF | cmp $testout - || exit 1
124 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
125 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
126 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, cwd = $tmpreal/ftwtest.d, level = 1
127 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
128 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_F, cwd = $tmpreal/ftwtest.d/bar, level = 2
129 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo, level = 2
130 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
131 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
132 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
133 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
134 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
135 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2/lvl3, level = 5