source: vendor/glibc-tests/glibc/posix/wordexp-tst.sh

Last change on this file was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1#!/bin/sh
2
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.
6
7common_objpfx=$1; shift
8elf_objpfx=$1; shift
9rtld_installed_name=$1; shift
10logfile=${common_objpfx}posix/wordexp-tst.out
11testout=${common_objpfx}posix/wordexp-test-result
12
13result=0
14rm -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.
17IFS=" \
18
19"
20export IFS
21
22failed=0
23${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
24${common_objpfx}posix/wordexp-test '$*' > ${testout}1
25cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
26wordexp returned 0
27we_wordv[0] = "$*"
28EOF
29if test $failed -ne 0; then
30 echo '$* test failed'
31 status=1
32fi
33
34failed=0
35${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
36${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
37cat <<"EOF" | cmp - ${testout}2 >> $logfile || failed=1
38wordexp returned 0
39we_wordv[0] = "${*}"
40we_wordv[1] = "unquoted"
41EOF
42if test $failed -ne 0; then
43 echo '${*} test failed'
44 status=1
45fi
46
47failed=0
48${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
49${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
50cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
51wordexp returned 0
52we_wordv[0] = "$@"
53we_wordv[1] = "unquoted"
54EOF
55if test $failed -ne 0; then
56 echo '$@ test failed'
57 status=1
58fi
59
60failed=0
61${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
62${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
63cat <<"EOF" | cmp - ${testout}4 >> $logfile || failed=1
64wordexp returned 0
65we_wordv[0] = ""$* quoted" param quoted"
66EOF
67if test $failed -ne 0; then
68 echo '$* quoted test failed'
69 status=1
70fi
71
72failed=0
73${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
74${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
75cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
76wordexp returned 0
77we_wordv[0] = ""$@ quoted""
78we_wordv[1] = "param quoted"
79EOF
80if test $failed -ne 0; then
81 echo '$@ quoted test failed'
82 status=1
83fi
84# Why? Because bash does it that way..
85
86failed=0
87${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
88${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
89cat <<"EOF" | cmp - ${testout}6 >> $logfile || failed=1
90wordexp returned 0
91we_wordv[0] = "5"
92EOF
93if test $failed -ne 0; then
94 echo '$# test failed'
95 status=1
96fi
97
98failed=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
101cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
102wordexp returned 0
103we_wordv[0] = "2nd"
104we_wordv[1] = "3rd"
105we_wordv[2] = "4"
106we_wordv[3] = "th"
107EOF
108if test $failed -ne 0; then
109 echo '$2 ${3} $4 test failed'
110 status=1
111fi
112
113failed=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
116cat <<"EOF" | cmp - ${testout}8 >> $logfile || failed=1
117wordexp returned 0
118we_wordv[0] = "11"
119EOF
120if test $failed -ne 0; then
121 echo '${11} test failed'
122 status=1
123fi
124
125failed=0
126${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
127${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
128cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
129wordexp returned 0
130we_wordv[0] = "a "a $@ b""
131we_wordv[1] = "c"
132we_wordv[2] = "d b"
133EOF
134if test $failed -ne 0; then
135 echo '"a $@ b" test failed'
136 status=1
137fi
138
139${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
140${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
141cat <<"EOF" | cmp - ${testout}10 || failed=1
142wordexp returned 0
143we_wordv[0] = "4"
144we_wordv[1] = "3"
145we_wordv[2] = "*${#@}"
146we_wordv[3] = "${#2}"
147we_wordv[4] = "*$**"
148we_wordv[5] = "two"
149we_wordv[6] = "3"
150we_wordv[7] = "4*"
151EOF
152
153exit $result
Note: See TracBrowser for help on using the repository browser.