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:
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
50 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D
51 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F
52 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D
53 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS
54 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D
55 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F
56 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN
57 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D
58 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F
59 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D
60 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F
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
69 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_DP
70 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F
71 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_DP
72 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS
73 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_DP
74 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F
75 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN
76 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_DP
77 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F
78 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_DP
79 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F
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
88 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D
89 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F
90 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D
91 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS
92 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D
93 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F
94 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SL
95 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D
96 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F
97 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "link@2", flag = FTW_SL
98 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D
99 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F
100 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "link@3", flag = FTW_SL