Add -D__LIBC_INTERNAL_MATH_INLINES.
[glibc/history.git] / io / ftwtest-sh
blob0ae6ecd51aedecb85bc3d7218b25273ac3df506c
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
15 # First create our scenario:
16 tmp=`echo ${TMPDIR:-/tmp} | sed 's|\(.\)/*$|\1|'`
17 tmpdir=$tmp/ftwtest.d
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
24 chmod -R a+x $tmpdir
25 rm -fr $tmpdir
27 mkdir $tmpdir
28 mkdir $tmpdir/foo
29 mkdir $tmpdir/bar
30 echo > $tmpdir/baz
31 mkdir $tmpdir/foo/lvl1
32 echo > $tmpdir/foo/lvl1/file@1
33 mkdir $tmpdir/foo/lvl1/lvl2
34 echo > $tmpdir/foo/lvl1/lvl2/file@2
35 mkdir $tmpdir/foo/lvl1/lvl2/lvl3
36 echo > $tmpdir/foo/lvl1/lvl2/lvl3/file@3
37 ln -s $tmpdir $tmpdir/foo/lvl1/lvl2/lvl3/link@3
38 ln -s $tmpdir/foo/lvl1/lvl2 $tmpdir/foo/lvl1/lvl2/link@2
39 ln -s $tmpdir/foo/lvl1/lvl2/lvl3/lvl4 $tmpdir/foo/lvl1/link@1
40 echo > $tmpdir/bar/xo
41 chmod a-x,a+r $tmpdir/bar
43 testout=${TMPDIR:-/tmp}/ftwtest.out
45 LD_LIBRARY_PATH=$objpfx $ldso $testprogram $tmpdir |
46 sort > $testout
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
61 EOF
62 rm $testout
64 LD_LIBRARY_PATH=$objpfx $ldso $testprogram --depth $tmpdir |
65 sort > $testout
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
80 EOF
81 rm $testout
83 LD_LIBRARY_PATH=$objpfx $ldso $testprogram --phys $tmpdir |
84 sort > $testout
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
102 rm $testout
104 # For the next test everything must be readable.
105 chmod -R a+x $tmpdir
107 LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir $tmpdir |
108 sort > $testout
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
127 rm $testout
129 rm -fr $tmpdir
131 exit 0