* sysdeps/unix/sysv/linux/m68k/vfork.S: New file.
[glibc.git] / io / ftwtest-sh
blobdadbfa0ca6f0ff81445047acbe87b898b3fbfd81
1 #! /bin/sh
3 # The common objpfx, used to find libraries and the dynamic loader.
4 objpfx=$1
6 # We expect one parameter which is the test program. This must understand
7 # a number options:
8 # --phys use the FTW_PHYS flag
9 # --chdir use the FTW_CHDIR and print the current directory in the
10 # callback
11 # --depth use the FTW_DEPTH flag
12 testprogram=$2
14 # We cannot test this as root.
15 if test `id | sed "s/uid=\([0-9]*\).*/\1/"` = 0; then
16 exit 0
19 # First create our scenario:
20 tmp=`echo ${TMPDIR:-/tmp} | sed 's|\(.\)/*$|\1|'`
21 tmpdir=$tmp/ftwtest.d
23 [ -f ${objpfx}elf/ld.so ] && ldso=${objpfx}elf/ld.so
25 trap 'chmod -R a+x $tmpdir; rm -fr $tmpdir $testout' 1 2 3 15
27 if test -d $tmpdir; then
28 chmod -R a+x $tmpdir
29 rm -fr $tmpdir
31 mkdir $tmpdir
32 mkdir $tmpdir/foo
33 mkdir $tmpdir/bar
34 echo > $tmpdir/baz
35 mkdir $tmpdir/foo/lvl1
36 echo > $tmpdir/foo/lvl1/file@1
37 mkdir $tmpdir/foo/lvl1/lvl2
38 echo > $tmpdir/foo/lvl1/lvl2/file@2
39 mkdir $tmpdir/foo/lvl1/lvl2/lvl3
40 echo > $tmpdir/foo/lvl1/lvl2/lvl3/file@3
41 ln -s $tmpdir $tmpdir/foo/lvl1/lvl2/lvl3/link@3
42 ln -s $tmpdir/foo/lvl1/lvl2 $tmpdir/foo/lvl1/lvl2/link@2
43 ln -s $tmpdir/foo/lvl1/lvl2/lvl3/lvl4 $tmpdir/foo/lvl1/link@1
44 echo > $tmpdir/bar/xo
45 chmod a-x,a+r $tmpdir/bar
47 testout=${TMPDIR:-/tmp}/ftwtest.out
49 LD_LIBRARY_PATH=$objpfx $ldso $testprogram $tmpdir |
50 sort > $testout
52 cat <<EOF | cmp $testout - || exit 1
53 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
54 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
55 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
56 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
57 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
58 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
59 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
60 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
61 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
62 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
63 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
64 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
65 EOF
66 rm $testout
68 LD_LIBRARY_PATH=$objpfx $ldso $testprogram --depth $tmpdir |
69 sort > $testout
71 cat <<EOF | cmp $testout - || exit 1
72 base = "$tmp/", file = "ftwtest.d", flag = FTW_DP, level = 0
73 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_DP, level = 1
74 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
75 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_DP, level = 1
76 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
77 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_DP, level = 2
78 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
79 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, level = 3
80 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_DP, level = 3
81 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
82 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_DP, level = 4
83 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
84 EOF
85 rm $testout
87 LD_LIBRARY_PATH=$objpfx $ldso $testprogram --phys $tmpdir |
88 sort > $testout
90 cat <<EOF | cmp $testout - || exit 1
91 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, level = 0
92 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, level = 1
93 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, level = 1
94 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, level = 1
95 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_NS, level = 2
96 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, level = 2
97 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, level = 3
98 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SL, level = 3
99 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, level = 3
100 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, level = 4
101 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "link@2", flag = FTW_SL, level = 4
102 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, level = 4
103 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, level = 5
104 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "link@3", flag = FTW_SL, level = 5
106 rm $testout
108 # For the next test everything must be readable.
109 chmod -R a+x $tmpdir
111 LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir $tmpdir |
112 sort > $testout
114 # perhaps $tmp involves some symlinks...
115 tmpreal=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd`
117 cat <<EOF | cmp $testout - || exit 1
118 base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
119 base = "$tmp/ftwtest.d/", file = "bar", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
120 base = "$tmp/ftwtest.d/", file = "baz", flag = FTW_F, cwd = $tmpreal/ftwtest.d, level = 1
121 base = "$tmp/ftwtest.d/", file = "foo", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
122 base = "$tmp/ftwtest.d/bar/", file = "xo", flag = FTW_F, cwd = $tmpreal/ftwtest.d/bar, level = 2
123 base = "$tmp/ftwtest.d/foo/", file = "lvl1", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo, level = 2
124 base = "$tmp/ftwtest.d/foo/lvl1/", file = "file@1", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
125 base = "$tmp/ftwtest.d/foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
126 base = "$tmp/ftwtest.d/foo/lvl1/", file = "lvl2", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
127 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
128 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
129 base = "$tmp/ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2/lvl3, level = 5
131 rm $testout
133 rm -fr $tmpdir
135 exit 0