Update.
[glibc.git] / posix / wordexp-tst.sh
blob8fe697e07d4e6cd590468d5198e942e352111129
1 #!/bin/sh
3 # Some of these tests may look a little weird.
4 # The first parameter to wordexp-test is what it gives to wordexp.
5 # The others are just there to be parameters.
7 common_objpfx=$1; shift
8 elf_objpfx=$1; shift
9 rtld_installed_name=$1; shift
10 logfile=$common_objpfx/posix/wordexp-tst.out
12 : ${TMPDIR=${common_objpfx}posix}
13 testout=$TMPDIR/wordexp-test-result
15 result=0
16 rm -f $logfile
17 # This is written in this funny way so that there is no trailing whitespace.
18 # The first line contains a space followed by a tab.
19 IFS=" \
22 export IFS
24 failed=0
25 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
26 ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
27 cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
28 wordexp returned 0
29 we_wordv[0] = "$*"
30 EOF
31 if test $failed -ne 0; then
32 echo '$* test failed'
33 status=1
36 failed=0
37 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
38 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
39 cat <<"EOF" | cmp - ${testout}2 >> $logfile || failed=1
40 wordexp returned 0
41 we_wordv[0] = "${*}"
42 we_wordv[1] = "unquoted"
43 EOF
44 if test $failed -ne 0; then
45 echo '${*} test failed'
46 status=1
49 failed=0
50 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
51 ${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
52 cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
53 wordexp returned 0
54 we_wordv[0] = "$@"
55 we_wordv[1] = "unquoted"
56 EOF
57 if test $failed -ne 0; then
58 echo '$@ test failed'
59 status=1
62 failed=0
63 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
64 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
65 cat <<"EOF" | cmp - ${testout}4 >> $logfile || failed=1
66 wordexp returned 0
67 we_wordv[0] = ""$* quoted" param quoted"
68 EOF
69 if test $failed -ne 0; then
70 echo '$* quoted test failed'
71 status=1
74 failed=0
75 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
76 ${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
77 cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
78 wordexp returned 0
79 we_wordv[0] = ""$@ quoted""
80 we_wordv[1] = "param quoted"
81 EOF
82 if test $failed -ne 0; then
83 echo '$@ quoted test failed'
84 status=1
86 # Why? Because bash does it that way..
88 failed=0
89 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
90 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
91 cat <<"EOF" | cmp - ${testout}6 >> $logfile || failed=1
92 wordexp returned 0
93 we_wordv[0] = "5"
94 EOF
95 if test $failed -ne 0; then
96 echo '$# test failed'
97 status=1
100 failed=0
101 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
102 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
103 cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
104 wordexp returned 0
105 we_wordv[0] = "2nd"
106 we_wordv[1] = "3rd"
107 we_wordv[2] = "4"
108 we_wordv[3] = "th"
110 if test $failed -ne 0; then
111 echo '$2 ${3} $4 test failed'
112 status=1
115 failed=0
116 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
117 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
118 cat <<"EOF" | cmp - ${testout}8 >> $logfile || failed=1
119 wordexp returned 0
120 we_wordv[0] = "11"
122 if test $failed -ne 0; then
123 echo '${11} test failed'
124 status=1
127 failed=0
128 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
129 ${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
130 cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
131 wordexp returned 0
132 we_wordv[0] = "a "a $@ b""
133 we_wordv[1] = "c"
134 we_wordv[2] = "d b"
136 if test $failed -ne 0; then
137 echo '"a $@ b" test failed'
138 status=1
141 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
142 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
143 cat <<"EOF" | cmp - ${testout}10 || failed=1
144 wordexp returned 0
145 we_wordv[0] = "4"
146 we_wordv[1] = "3"
147 we_wordv[2] = "*${#@}"
148 we_wordv[3] = "${#2}"
149 we_wordv[4] = "*$**"
150 we_wordv[5] = "two"
151 we_wordv[6] = "3"
152 we_wordv[7] = "4*"
155 exit $result