Fix another x86 sys/ucontext.h namespace issue (bug 21457).
[glibc.git] / posix / wordexp-tst.sh
blobfb571a74cc19b9a898336da6ef89c4252839676d
1 #!/bin/sh
2 # Test for wordexp(3).
3 # Copyright (C) 1998-2017 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
20 set -e
22 # Some of these tests may look a little weird.
23 # The first parameter to wordexp-test is what it gives to wordexp.
24 # The others are just there to be parameters.
26 common_objpfx=$1; shift
27 test_program_prefix_before_env=$1; shift
28 run_program_env=$1; shift
29 test_program_prefix_after_env=$1; shift
30 logfile=${common_objpfx}posix/wordexp-tst.out
31 testout=${common_objpfx}posix/wordexp-test-result
33 result=0
34 rm -f $logfile
35 # This is written in this funny way so that there is no trailing whitespace.
36 # The first line contains a space followed by a tab.
37 IFS=" \
40 export IFS
42 failed=0
43 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
44 ${test_program_prefix_after_env} \
45 ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
46 cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
47 wordexp returned 0
48 we_wordv[0] = "$*"
49 EOF
50 if test $failed -ne 0; then
51 echo '$* test failed'
52 status=1
55 failed=0
56 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
57 ${test_program_prefix_after_env} \
58 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
59 cat <<"EOF" | cmp - ${testout}2 >> $logfile || failed=1
60 wordexp returned 0
61 we_wordv[0] = "${*}"
62 we_wordv[1] = "unquoted"
63 EOF
64 if test $failed -ne 0; then
65 echo '${*} test failed'
66 status=1
69 failed=0
70 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
71 ${test_program_prefix_after_env} \
72 ${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
73 cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
74 wordexp returned 0
75 we_wordv[0] = "$@"
76 we_wordv[1] = "unquoted"
77 EOF
78 if test $failed -ne 0; then
79 echo '$@ test failed'
80 status=1
83 failed=0
84 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
85 ${test_program_prefix_after_env} \
86 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
87 cat <<"EOF" | cmp - ${testout}4 >> $logfile || failed=1
88 wordexp returned 0
89 we_wordv[0] = ""$* quoted" param quoted"
90 EOF
91 if test $failed -ne 0; then
92 echo '$* quoted test failed'
93 status=1
96 failed=0
97 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
98 ${test_program_prefix_after_env} \
99 ${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
100 cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
101 wordexp returned 0
102 we_wordv[0] = ""$@ quoted""
103 we_wordv[1] = "param quoted"
105 if test $failed -ne 0; then
106 echo '$@ quoted test failed'
107 status=1
109 # Why? Because bash does it that way..
111 failed=0
112 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
113 ${test_program_prefix_after_env} \
114 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
115 cat <<"EOF" | cmp - ${testout}6 >> $logfile || failed=1
116 wordexp returned 0
117 we_wordv[0] = "5"
119 if test $failed -ne 0; then
120 echo '$# test failed'
121 status=1
124 failed=0
125 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
126 ${test_program_prefix_after_env} \
127 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
128 cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
129 wordexp returned 0
130 we_wordv[0] = "2nd"
131 we_wordv[1] = "3rd"
132 we_wordv[2] = "4"
133 we_wordv[3] = "th"
135 if test $failed -ne 0; then
136 echo '$2 ${3} $4 test failed'
137 status=1
140 failed=0
141 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
142 ${test_program_prefix_after_env} \
143 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
144 cat <<"EOF" | cmp - ${testout}8 >> $logfile || failed=1
145 wordexp returned 0
146 we_wordv[0] = "11"
148 if test $failed -ne 0; then
149 echo '${11} test failed'
150 status=1
153 failed=0
154 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
155 ${test_program_prefix_after_env} \
156 ${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
157 cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
158 wordexp returned 0
159 we_wordv[0] = "a "a $@ b""
160 we_wordv[1] = "c"
161 we_wordv[2] = "d b"
163 if test $failed -ne 0; then
164 echo '"a $@ b" test failed'
165 status=1
168 ${test_program_prefix_before_env} ${run_program_env} IFS="$IFS" \
169 ${test_program_prefix_after_env} \
170 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
171 cat <<"EOF" | cmp - ${testout}10 || failed=1
172 wordexp returned 0
173 we_wordv[0] = "4"
174 we_wordv[1] = "3"
175 we_wordv[2] = "*${#@}"
176 we_wordv[3] = "${#2}"
177 we_wordv[4] = "*$**"
178 we_wordv[5] = "two"
179 we_wordv[6] = "3"
180 we_wordv[7] = "4*"
183 exit $result