Add copyright notices to testsuite shell scripts
[platform/upstream/glibc.git] / posix / wordexp-tst.sh
1 #! /bin/sh
2 # Test for wordexp(3).
3 # Copyright (C) 1998-2000 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
5
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.
10
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.
15
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/>.
19
20 # Some of these tests may look a little weird.
21 # The first parameter to wordexp-test is what it gives to wordexp.
22 # The others are just there to be parameters.
23
24 common_objpfx=$1; shift
25 elf_objpfx=$1; shift
26 rtld_installed_name=$1; shift
27 logfile=${common_objpfx}posix/wordexp-tst.out
28 testout=${common_objpfx}posix/wordexp-test-result
29
30 result=0
31 rm -f $logfile
32 # This is written in this funny way so that there is no trailing whitespace.
33 # The first line contains a space followed by a tab.
34 IFS="   \
35
36 "
37 export IFS
38
39 failed=0
40 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
41 ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
42 cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
43 wordexp returned 0
44 we_wordv[0] = "$*"
45 EOF
46 if test $failed -ne 0; then
47   echo '$* test failed'
48   status=1
49 fi
50
51 failed=0
52 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
53 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
54 cat <<"EOF" | cmp - ${testout}2 >> $logfile || failed=1
55 wordexp returned 0
56 we_wordv[0] = "${*}"
57 we_wordv[1] = "unquoted"
58 EOF
59 if test $failed -ne 0; then
60   echo '${*} test failed'
61   status=1
62 fi
63
64 failed=0
65 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
66 ${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
67 cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
68 wordexp returned 0
69 we_wordv[0] = "$@"
70 we_wordv[1] = "unquoted"
71 EOF
72 if test $failed -ne 0; then
73   echo '$@ test failed'
74   status=1
75 fi
76
77 failed=0
78 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
79 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
80 cat <<"EOF" | cmp - ${testout}4 >> $logfile || failed=1
81 wordexp returned 0
82 we_wordv[0] = ""$* quoted" param quoted"
83 EOF
84 if test $failed -ne 0; then
85   echo '$* quoted test failed'
86   status=1
87 fi
88
89 failed=0
90 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
91 ${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
92 cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
93 wordexp returned 0
94 we_wordv[0] = ""$@ quoted""
95 we_wordv[1] = "param quoted"
96 EOF
97 if test $failed -ne 0; then
98   echo '$@ quoted test failed'
99   status=1
100 fi
101 # Why?  Because bash does it that way..
102
103 failed=0
104 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
105 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
106 cat <<"EOF" | cmp - ${testout}6 >> $logfile || failed=1
107 wordexp returned 0
108 we_wordv[0] = "5"
109 EOF
110 if test $failed -ne 0; then
111   echo '$# test failed'
112   status=1
113 fi
114
115 failed=0
116 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
117 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
118 cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
119 wordexp returned 0
120 we_wordv[0] = "2nd"
121 we_wordv[1] = "3rd"
122 we_wordv[2] = "4"
123 we_wordv[3] = "th"
124 EOF
125 if test $failed -ne 0; then
126   echo '$2 ${3} $4 test failed'
127   status=1
128 fi
129
130 failed=0
131 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
132 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
133 cat <<"EOF" | cmp - ${testout}8 >> $logfile || failed=1
134 wordexp returned 0
135 we_wordv[0] = "11"
136 EOF
137 if test $failed -ne 0; then
138   echo '${11} test failed'
139   status=1
140 fi
141
142 failed=0
143 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
144 ${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
145 cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
146 wordexp returned 0
147 we_wordv[0] = "a "a $@ b""
148 we_wordv[1] = "c"
149 we_wordv[2] = "d b"
150 EOF
151 if test $failed -ne 0; then
152   echo '"a $@ b" test failed'
153   status=1
154 fi
155
156 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
157 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
158 cat <<"EOF" | cmp - ${testout}10 || failed=1
159 wordexp returned 0
160 we_wordv[0] = "4"
161 we_wordv[1] = "3"
162 we_wordv[2] = "*${#@}"
163 we_wordv[3] = "${#2}"
164 we_wordv[4] = "*$**"
165 we_wordv[5] = "two"
166 we_wordv[6] = "3"
167 we_wordv[7] = "4*"
168 EOF
169
170 exit $result