]>
Commit | Line | Data |
---|---|---|
14c44e2e UD |
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 | ||
7 | common_objpfx=$1; shift | |
8 | elf_objpfx=$1; shift | |
9 | rtld_installed_name=$1; shift | |
10 | ||
67600288 | 11 | : ${TMPDIR=${common_objpfx}posix} |
14c44e2e UD |
12 | testout=$TMPDIR/wordexp-test-result |
13 | ||
14 | failed=0 | |
31161268 UD |
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=" \ | |
18 | ||
19 | " | |
20 | export IFS | |
21 | ||
14c44e2e UD |
22 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ |
23 | ${common_objpfx}posix/wordexp-test '$*' > ${testout}1 | |
24 | cat <<"EOF" | cmp - ${testout}1 || failed=1 | |
25 | wordexp returned 0 | |
26 | we_wordv[0] = "$*" | |
27 | EOF | |
28 | ||
29 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ | |
30 | ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2 | |
31 | cat <<"EOF" | cmp - ${testout}2 || failed=1 | |
32 | wordexp returned 0 | |
33 | we_wordv[0] = "${*}" | |
34 | we_wordv[1] = "unquoted" | |
35 | EOF | |
36 | ||
37 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ | |
38 | ${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3 | |
39 | cat <<"EOF" | cmp - ${testout}3 || failed=1 | |
40 | wordexp returned 0 | |
41 | we_wordv[0] = "$@" | |
42 | we_wordv[1] = "unquoted" | |
43 | EOF | |
44 | ||
45 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ | |
46 | ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4 | |
47 | cat <<"EOF" | cmp - ${testout}4 || failed=1 | |
48 | wordexp returned 0 | |
49 | we_wordv[0] = ""$* quoted" param quoted" | |
50 | EOF | |
51 | ||
52 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ | |
53 | ${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5 | |
54 | cat <<"EOF" | cmp - ${testout}5 || failed=1 | |
55 | wordexp returned 0 | |
56 | we_wordv[0] = ""$@ quoted"" | |
57 | we_wordv[1] = "param quoted" | |
58 | EOF | |
59 | # Why? Because bash does it that way.. | |
60 | ||
61 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ | |
62 | ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6 | |
63 | cat <<"EOF" | cmp - ${testout}6 || failed=1 | |
64 | wordexp returned 0 | |
65 | we_wordv[0] = "5" | |
66 | EOF | |
67 | ||
68 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ | |
76fbcfdd UD |
69 | ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7 |
70 | cat <<"EOF" | cmp - ${testout}7 || failed=1 | |
14c44e2e UD |
71 | wordexp returned 0 |
72 | we_wordv[0] = "2nd" | |
73 | we_wordv[1] = "3rd" | |
76fbcfdd UD |
74 | we_wordv[2] = "4" |
75 | we_wordv[3] = "th" | |
14c44e2e UD |
76 | EOF |
77 | ||
31161268 UD |
78 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ |
79 | ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8 | |
80 | cat <<"EOF" | cmp - ${testout}8 || failed=1 | |
81 | wordexp returned 0 | |
82 | we_wordv[0] = "11" | |
83 | EOF | |
84 | ||
85 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ | |
86 | ${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9 | |
87 | cat <<"EOF" | cmp - ${testout}9 || failed=1 | |
88 | wordexp returned 0 | |
89 | we_wordv[0] = "a "a $@ b"" | |
90 | we_wordv[1] = "c" | |
91 | we_wordv[2] = "d b" | |
92 | EOF | |
93 | ||
e9fc7bbb UD |
94 | ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \ |
95 | ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10 | |
96 | cat <<"EOF" | cmp - ${testout}10 || failed=1 | |
97 | wordexp returned 0 | |
98 | we_wordv[0] = "4" | |
99 | we_wordv[1] = "3" | |
100 | we_wordv[2] = "*${#@}" | |
101 | we_wordv[3] = "${#2}" | |
102 | we_wordv[4] = "*$**" | |
103 | we_wordv[5] = "two" | |
104 | we_wordv[6] = "3" | |
105 | we_wordv[7] = "4*" | |
106 | EOF | |
107 | ||
14c44e2e | 108 | exit $failed |