* sysdeps/unix/bsd/hp: Directory and all files removed.
[glibc.git] / posix / wordexp-tst.sh
blob9654457f5a77f3bc38fad9951fae67b1d895a403
1 #!/bin/sh
3 # Some of these tests may look a little weird.
4 # The first parameter to wordexp-test is what it gives to wordexp.
5 # The others are just there to be parameters.
7 common_objpfx=$1; shift
8 elf_objpfx=$1; shift
9 rtld_installed_name=$1; shift
10 logfile=${common_objpfx}posix/wordexp-tst.out
11 testout=${common_objpfx}posix/wordexp-test-result
13 result=0
14 rm -f $logfile
15 # This is written in this funny way so that there is no trailing whitespace.
16 # The first line contains a space followed by a tab.
17 IFS=" \
20 export IFS
22 failed=0
23 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
24 ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
25 cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
26 wordexp returned 0
27 we_wordv[0] = "$*"
28 EOF
29 if test $failed -ne 0; then
30 echo '$* test failed'
31 status=1
34 failed=0
35 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
36 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
37 cat <<"EOF" | cmp - ${testout}2 >> $logfile || failed=1
38 wordexp returned 0
39 we_wordv[0] = "${*}"
40 we_wordv[1] = "unquoted"
41 EOF
42 if test $failed -ne 0; then
43 echo '${*} test failed'
44 status=1
47 failed=0
48 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
49 ${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
50 cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
51 wordexp returned 0
52 we_wordv[0] = "$@"
53 we_wordv[1] = "unquoted"
54 EOF
55 if test $failed -ne 0; then
56 echo '$@ test failed'
57 status=1
60 failed=0
61 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
62 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
63 cat <<"EOF" | cmp - ${testout}4 >> $logfile || failed=1
64 wordexp returned 0
65 we_wordv[0] = ""$* quoted" param quoted"
66 EOF
67 if test $failed -ne 0; then
68 echo '$* quoted test failed'
69 status=1
72 failed=0
73 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
74 ${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
75 cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
76 wordexp returned 0
77 we_wordv[0] = ""$@ quoted""
78 we_wordv[1] = "param quoted"
79 EOF
80 if test $failed -ne 0; then
81 echo '$@ quoted test failed'
82 status=1
84 # Why? Because bash does it that way..
86 failed=0
87 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
88 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
89 cat <<"EOF" | cmp - ${testout}6 >> $logfile || failed=1
90 wordexp returned 0
91 we_wordv[0] = "5"
92 EOF
93 if test $failed -ne 0; then
94 echo '$# test failed'
95 status=1
98 failed=0
99 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
100 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
101 cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
102 wordexp returned 0
103 we_wordv[0] = "2nd"
104 we_wordv[1] = "3rd"
105 we_wordv[2] = "4"
106 we_wordv[3] = "th"
108 if test $failed -ne 0; then
109 echo '$2 ${3} $4 test failed'
110 status=1
113 failed=0
114 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
115 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
116 cat <<"EOF" | cmp - ${testout}8 >> $logfile || failed=1
117 wordexp returned 0
118 we_wordv[0] = "11"
120 if test $failed -ne 0; then
121 echo '${11} test failed'
122 status=1
125 failed=0
126 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
127 ${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
128 cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
129 wordexp returned 0
130 we_wordv[0] = "a "a $@ b""
131 we_wordv[1] = "c"
132 we_wordv[2] = "d b"
134 if test $failed -ne 0; then
135 echo '"a $@ b" test failed'
136 status=1
139 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
140 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
141 cat <<"EOF" | cmp - ${testout}10 || failed=1
142 wordexp returned 0
143 we_wordv[0] = "4"
144 we_wordv[1] = "3"
145 we_wordv[2] = "*${#@}"
146 we_wordv[3] = "${#2}"
147 we_wordv[4] = "*$**"
148 we_wordv[5] = "two"
149 we_wordv[6] = "3"
150 we_wordv[7] = "4*"
153 exit $result