3 # Copyright (C) 1998-2014 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
=$1; shift
28 logfile
=${common_objpfx}posix
/wordexp-tst.out
29 testout
=${common_objpfx}posix
/wordexp-test-result
33 # This is written in this funny way so that there is no trailing whitespace.
34 # The first line contains a space followed by a tab.
41 ${test_program_prefix} \
42 ${common_objpfx}posix
/wordexp-test
'$*' > ${testout}1
43 cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
47 if test $failed -ne 0; then
53 ${test_program_prefix} \
54 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
55 cat <<"EOF" |
cmp - ${testout}2 >> $logfile || failed
=1
58 we_wordv
[1] = "unquoted"
60 if test $failed -ne 0; then
61 echo '${*} test failed'
66 ${test_program_prefix} \
67 ${common_objpfx}posix
/wordexp-test
'$@' unquoted
> ${testout}3
68 cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
71 we_wordv[1] = "unquoted"
73 if test $failed -ne 0; then
79 ${test_program_prefix} \
80 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
81 cat <<"EOF" |
cmp - ${testout}4 >> $logfile || failed
=1
83 we_wordv
[0] = ""$
* quoted
" param quoted"
85 if test $failed -ne 0; then
86 echo '$* quoted test failed'
91 ${test_program_prefix} \
92 ${common_objpfx}posix
/wordexp-test
'"$@ quoted"' param
> ${testout}5
93 cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
95 we_wordv[0] = ""$@ quoted""
96 we_wordv[1] = "param quoted"
98 if test $failed -ne 0; then
99 echo '$@ quoted test failed'
102 # Why? Because bash does it that way..
105 ${test_program_prefix} \
106 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
107 cat <<"EOF" |
cmp - ${testout}6 >> $logfile || failed
=1
111 if test $failed -ne 0; then
112 echo '$# test failed'
117 ${test_program_prefix} \
118 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
119 cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
126 if test $failed -ne 0; then
127 echo '$2 ${3} $4 test failed'
132 ${test_program_prefix} \
133 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
134 cat <<"EOF" |
cmp - ${testout}8 >> $logfile || failed
=1
138 if test $failed -ne 0; then
139 echo '${11} test failed'
144 ${test_program_prefix} \
145 ${common_objpfx}posix
/wordexp-test
'"a $@ b"' c d
> ${testout}9
146 cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
148 we_wordv[0] = "a "a $@ b""
152 if test $failed -ne 0; then
153 echo '"a $@ b" test failed'
157 ${test_program_prefix} \
158 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
159 cat <<"EOF" |
cmp - ${testout}10 || failed
=1
163 we_wordv
[2] = "*${#@}"
164 we_wordv
[3] = "${#2}"