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
9 rtld_installed_name
=$1; shift
10 logfile
=$common_objpfx/posix
/wordexp-tst.out
12 : ${TMPDIR=${common_objpfx}posix}
13 testout
=$TMPDIR/wordexp-test-result
17 # This is written in this funny way so that there is no trailing whitespace.
18 # The first line contains a space followed by a tab.
25 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
26 ${common_objpfx}posix
/wordexp-test
'$*' > ${testout}1
27 cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
31 if test $failed -ne 0; then
37 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
38 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
39 cat <<"EOF" |
cmp - ${testout}2 >> $logfile || failed
=1
42 we_wordv
[1] = "unquoted"
44 if test $failed -ne 0; then
45 echo '${*} test failed'
50 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
51 ${common_objpfx}posix
/wordexp-test
'$@' unquoted
> ${testout}3
52 cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
55 we_wordv[1] = "unquoted"
57 if test $failed -ne 0; then
63 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
64 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
65 cat <<"EOF" |
cmp - ${testout}4 >> $logfile || failed
=1
67 we_wordv
[0] = ""$
* quoted
" param quoted"
69 if test $failed -ne 0; then
70 echo '$* quoted test failed'
75 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
76 ${common_objpfx}posix
/wordexp-test
'"$@ quoted"' param
> ${testout}5
77 cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
79 we_wordv[0] = ""$@ quoted""
80 we_wordv[1] = "param quoted"
82 if test $failed -ne 0; then
83 echo '$@ quoted test failed'
86 # Why? Because bash does it that way..
89 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
90 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
91 cat <<"EOF" |
cmp - ${testout}6 >> $logfile || failed
=1
95 if test $failed -ne 0; then
101 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
102 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
103 cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
110 if test $failed -ne 0; then
111 echo '$2 ${3} $4 test failed'
116 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
117 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
118 cat <<"EOF" |
cmp - ${testout}8 >> $logfile || failed
=1
122 if test $failed -ne 0; then
123 echo '${11} test failed'
128 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
129 ${common_objpfx}posix
/wordexp-test
'"a $@ b"' c d
> ${testout}9
130 cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
132 we_wordv[0] = "a "a $@ b""
136 if test $failed -ne 0; then
137 echo '"a $@ b" test failed'
141 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
142 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
143 cat <<"EOF" |
cmp - ${testout}10 || failed
=1
147 we_wordv
[2] = "*${#@}"
148 we_wordv
[3] = "${#2}"