Fix a typo in ChangeLog
[glibc.git] / posix / wordexp-tst.sh
blobfec529265b10ce1e462e047ad01b9c23ae2f6646
1 #! /bin/sh
2 # Test for wordexp(3).
3 # Copyright (C) 1998-2012 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 elf_objpfx=$1; shift
28 rtld_installed_name=$1; shift
29 logfile=${common_objpfx}posix/wordexp-tst.out
30 testout=${common_objpfx}posix/wordexp-test-result
32 result=0
33 rm -f $logfile
34 # This is written in this funny way so that there is no trailing whitespace.
35 # The first line contains a space followed by a tab.
36 IFS=" \
39 export IFS
41 failed=0
42 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
43 ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
44 cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
45 wordexp returned 0
46 we_wordv[0] = "$*"
47 EOF
48 if test $failed -ne 0; then
49 echo '$* test failed'
50 status=1
53 failed=0
54 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
55 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
56 cat <<"EOF" | cmp - ${testout}2 >> $logfile || failed=1
57 wordexp returned 0
58 we_wordv[0] = "${*}"
59 we_wordv[1] = "unquoted"
60 EOF
61 if test $failed -ne 0; then
62 echo '${*} test failed'
63 status=1
66 failed=0
67 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
68 ${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
69 cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
70 wordexp returned 0
71 we_wordv[0] = "$@"
72 we_wordv[1] = "unquoted"
73 EOF
74 if test $failed -ne 0; then
75 echo '$@ test failed'
76 status=1
79 failed=0
80 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
81 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
82 cat <<"EOF" | cmp - ${testout}4 >> $logfile || failed=1
83 wordexp returned 0
84 we_wordv[0] = ""$* quoted" param quoted"
85 EOF
86 if test $failed -ne 0; then
87 echo '$* quoted test failed'
88 status=1
91 failed=0
92 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
93 ${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
94 cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
95 wordexp returned 0
96 we_wordv[0] = ""$@ quoted""
97 we_wordv[1] = "param quoted"
98 EOF
99 if test $failed -ne 0; then
100 echo '$@ quoted test failed'
101 status=1
103 # Why? Because bash does it that way..
105 failed=0
106 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
107 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
108 cat <<"EOF" | cmp - ${testout}6 >> $logfile || failed=1
109 wordexp returned 0
110 we_wordv[0] = "5"
112 if test $failed -ne 0; then
113 echo '$# test failed'
114 status=1
117 failed=0
118 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
119 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
120 cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
121 wordexp returned 0
122 we_wordv[0] = "2nd"
123 we_wordv[1] = "3rd"
124 we_wordv[2] = "4"
125 we_wordv[3] = "th"
127 if test $failed -ne 0; then
128 echo '$2 ${3} $4 test failed'
129 status=1
132 failed=0
133 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
134 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
135 cat <<"EOF" | cmp - ${testout}8 >> $logfile || failed=1
136 wordexp returned 0
137 we_wordv[0] = "11"
139 if test $failed -ne 0; then
140 echo '${11} test failed'
141 status=1
144 failed=0
145 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
146 ${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
147 cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
148 wordexp returned 0
149 we_wordv[0] = "a "a $@ b""
150 we_wordv[1] = "c"
151 we_wordv[2] = "d b"
153 if test $failed -ne 0; then
154 echo '"a $@ b" test failed'
155 status=1
158 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
159 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
160 cat <<"EOF" | cmp - ${testout}10 || failed=1
161 wordexp returned 0
162 we_wordv[0] = "4"
163 we_wordv[1] = "3"
164 we_wordv[2] = "*${#@}"
165 we_wordv[3] = "${#2}"
166 we_wordv[4] = "*$**"
167 we_wordv[5] = "two"
168 we_wordv[6] = "3"
169 we_wordv[7] = "4*"
172 exit $result