3 # Copyright (C) 1998-2016 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/>.
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
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.
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
50 if test $failed -ne 0; then
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
62 we_wordv
[1] = "unquoted"
64 if test $failed -ne 0; then
65 echo '${*} test failed'
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
76 we_wordv[1] = "unquoted"
78 if test $failed -ne 0; then
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
89 we_wordv
[0] = ""$
* quoted
" param quoted"
91 if test $failed -ne 0; then
92 echo '$* quoted test failed'
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
102 we_wordv[0] = ""$@ quoted""
103 we_wordv[1] = "param quoted"
105 if test $failed -ne 0; then
106 echo '$@ quoted test failed'
109 # Why? Because bash does it that way..
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
119 if test $failed -ne 0; then
120 echo '$# test failed'
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
135 if test $failed -ne 0; then
136 echo '$2 ${3} $4 test failed'
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
148 if test $failed -ne 0; then
149 echo '${11} test failed'
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
159 we_wordv[0] = "a "a $@ b""
163 if test $failed -ne 0; then
164 echo '"a $@ b" test failed'
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
175 we_wordv
[2] = "*${#@}"
176 we_wordv
[3] = "${#2}"