diff options
Diffstat (limited to '')
-rwxr-xr-x | testsuite/awk.tests | 14 | ||||
-rwxr-xr-x | testsuite/busybox.tests | 19 | ||||
-rwxr-xr-x | testsuite/cpio.tests | 23 | ||||
-rwxr-xr-x | testsuite/cryptpw.tests | 98 | ||||
-rwxr-xr-x | testsuite/diff.tests | 63 | ||||
-rwxr-xr-x | testsuite/env.tests | 71 | ||||
-rwxr-xr-x | testsuite/hexdump.tests | 91 | ||||
-rwxr-xr-x | testsuite/make.tests | 805 | ||||
-rwxr-xr-x | testsuite/od.tests | 13 | ||||
-rwxr-xr-x | testsuite/runtest | 18 | ||||
-rwxr-xr-x | testsuite/sh.tests | 118 | ||||
-rw-r--r-- | testsuite/wget/wget-handles-https | 4 |
12 files changed, 1295 insertions, 42 deletions
diff --git a/testsuite/awk.tests b/testsuite/awk.tests index be25f6696..af9ed5359 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests | |||
@@ -480,6 +480,20 @@ testing 'awk backslash+newline eaten with no trace' \ | |||
480 | "Hello world\n" \ | 480 | "Hello world\n" \ |
481 | '' '' | 481 | '' '' |
482 | 482 | ||
483 | optional PLATFORM_MINGW32 | ||
484 | testing 'awk match line ending' \ | ||
485 | "awk '/world$/'" \ | ||
486 | "world\n" \ | ||
487 | "" \ | ||
488 | "hello\r\nworld\r\n" | ||
489 | |||
490 | testing 'awk backslash+CRLF eaten with no trace' \ | ||
491 | "awk -f -" \ | ||
492 | "Hello world\n" \ | ||
493 | '' \ | ||
494 | 'BEGIN { printf "Hello\\\r\n world\\n" }\n' | ||
495 | SKIP= | ||
496 | |||
483 | # User-supplied bug (SEGV) example, was causing use-after-realloc | 497 | # User-supplied bug (SEGV) example, was causing use-after-realloc |
484 | testing 'awk assign while assign' \ | 498 | testing 'awk assign while assign' \ |
485 | "awk '\$5=\$\$5=\$0'; echo \$?" \ | 499 | "awk '\$5=\$\$5=\$0'; echo \$?" \ |
diff --git a/testsuite/busybox.tests b/testsuite/busybox.tests index beb17440c..2ce09b281 100755 --- a/testsuite/busybox.tests +++ b/testsuite/busybox.tests | |||
@@ -7,11 +7,22 @@ | |||
7 | . ./testing.sh | 7 | . ./testing.sh |
8 | test -f "$bindir/.config" && . "$bindir/.config" | 8 | test -f "$bindir/.config" && . "$bindir/.config" |
9 | 9 | ||
10 | ln -s `which busybox` unknown | 10 | if [ -f "$bindir/busybox.exe" ]; then |
11 | # Copy rather than link busybox.exe: we can only make hard | ||
12 | # links which can't be deleted because Windows sees the | ||
13 | # executable as running. | ||
14 | suffix=".exe" | ||
15 | lncmd="cp" | ||
16 | else | ||
17 | suffix="" | ||
18 | lncmd="ln -s" | ||
19 | fi | ||
20 | |||
21 | $lncmd "$(which busybox)" unknown$suffix | ||
11 | 22 | ||
12 | testing "busybox as unknown name" "./unknown 2>&1" \ | 23 | testing "busybox as unknown name" "./unknown 2>&1" \ |
13 | "unknown: applet not found\n" "" "" | 24 | "unknown: applet not found\n" "" "" |
14 | rm unknown | 25 | rm unknown$suffix |
15 | 26 | ||
16 | # We need busybox --help to be enabled for the rest of tests | 27 | # We need busybox --help to be enabled for the rest of tests |
17 | test x"$CONFIG_BUSYBOX" = x"y" \ | 28 | test x"$CONFIG_BUSYBOX" = x"y" \ |
@@ -23,7 +34,7 @@ optional FEATURE_VERBOSE_USAGE | |||
23 | testing "busybox --help busybox" "true | busybox --help busybox 2>&1 | cat" "$HELPDUMP\n" "" "" | 34 | testing "busybox --help busybox" "true | busybox --help busybox 2>&1 | cat" "$HELPDUMP\n" "" "" |
24 | SKIP= | 35 | SKIP= |
25 | 36 | ||
26 | ln -s `which busybox` busybox-suffix | 37 | $lncmd "$(which busybox)" busybox-suffix$suffix |
27 | for i in busybox ./busybox-suffix | 38 | for i in busybox ./busybox-suffix |
28 | do | 39 | do |
29 | testing "$i" "$i 2>&1 | cat" "$HELPDUMP\n" "" "" | 40 | testing "$i" "$i 2>&1 | cat" "$HELPDUMP\n" "" "" |
@@ -42,6 +53,6 @@ do | |||
42 | testing "$i --help unknown" "$i --help unknown 2>&1" \ | 53 | testing "$i --help unknown" "$i --help unknown 2>&1" \ |
43 | "unknown: applet not found\n" "" "" | 54 | "unknown: applet not found\n" "" "" |
44 | done | 55 | done |
45 | rm busybox-suffix | 56 | rm busybox-suffix$suffix |
46 | 57 | ||
47 | exit $FAILCOUNT | 58 | exit $FAILCOUNT |
diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests index 85e746589..a4462c53e 100755 --- a/testsuite/cpio.tests +++ b/testsuite/cpio.tests | |||
@@ -154,6 +154,29 @@ testing "cpio -R with extract" \ | |||
154 | " "" "" | 154 | " "" "" |
155 | SKIP= | 155 | SKIP= |
156 | 156 | ||
157 | # Create an archive containing a file with "../dont_write" filename. | ||
158 | # See that it will not be allowed to unpack. | ||
159 | # NB: GNU cpio 2.15 DOES NOT do such checks. | ||
160 | optional FEATURE_PATH_TRAVERSAL_PROTECTION | ||
161 | rm -rf cpio.testdir | ||
162 | mkdir -p cpio.testdir/prepare/inner | ||
163 | echo "file outside of destination was written" > cpio.testdir/prepare/dont_write | ||
164 | echo "data" > cpio.testdir/prepare/inner/to_extract | ||
165 | mkdir -p cpio.testdir/extract | ||
166 | testing "cpio extract file outside of destination" "\ | ||
167 | (cd cpio.testdir/prepare/inner && echo -e '../dont_write\nto_extract' | cpio -o -H newc) | (cd cpio.testdir/extract && cpio -vi 2>&1) | ||
168 | echo \$? | ||
169 | ls cpio.testdir/dont_write 2>&1" \ | ||
170 | "\ | ||
171 | cpio: removing leading '../' from member names | ||
172 | ../dont_write | ||
173 | to_extract | ||
174 | 1 blocks | ||
175 | 0 | ||
176 | ls: cpio.testdir/dont_write: No such file or directory | ||
177 | " "" "" | ||
178 | SKIP= | ||
179 | |||
157 | # Clean up | 180 | # Clean up |
158 | rm -rf cpio.testdir cpio.testdir2 2>/dev/null | 181 | rm -rf cpio.testdir cpio.testdir2 2>/dev/null |
159 | 182 | ||
diff --git a/testsuite/cryptpw.tests b/testsuite/cryptpw.tests index 0dd91fe15..83bfde521 100755 --- a/testsuite/cryptpw.tests +++ b/testsuite/cryptpw.tests | |||
@@ -22,21 +22,93 @@ testing "cryptpw des zz" \ | |||
22 | #SKIP= | 22 | #SKIP= |
23 | 23 | ||
24 | optional USE_BB_CRYPT_SHA | 24 | optional USE_BB_CRYPT_SHA |
25 | testing "cryptpw sha256" \ | 25 | # Note: mkpasswd-5.6.2 won't accept "-m sha256", wants "-m sha256crypt" |
26 | "cryptpw -m sha256 QWErty '123456789012345678901234567890'" \ | 26 | testing 'cryptpw sha256' \ |
27 | '$5$1234567890123456$5DxfOCmU4vRhtzfsbdK.6wSGMwwVbac7ZkWwusb8Si7\n' "" "" | 27 | 'cryptpw -m sha256 QWErty 1234567890123456' \ |
28 | '$5$1234567890123456$5DxfOCmU4vRhtzfsbdK.6wSGMwwVbac7ZkWwusb8Si7\n' \ | ||
29 | '' '' | ||
30 | # mkpasswd-5.6.2 does not allow overlong salts, we truncate (at 16 chars for sha256) | ||
31 | testing 'cryptpw sha256 overlong' \ | ||
32 | 'cryptpw -m sha256 QWErty 123456789012345678901234567890' \ | ||
33 | '$5$1234567890123456$5DxfOCmU4vRhtzfsbdK.6wSGMwwVbac7ZkWwusb8Si7\n' \ | ||
34 | '' '' | ||
35 | testing 'cryptpw sha256 implicit' \ | ||
36 | 'cryptpw QWErty \$5\$1234567890123456' \ | ||
37 | '$5$1234567890123456$5DxfOCmU4vRhtzfsbdK.6wSGMwwVbac7ZkWwusb8Si7\n' \ | ||
38 | '' '' | ||
39 | testing 'cryptpw sha256 rounds=99999' \ | ||
40 | 'cryptpw -m sha256 QWErty rounds=99999\$123456789012345678901234567890' \ | ||
41 | '$5$rounds=99999$1234567890123456$aYellycJGZM6AKyVzaQsSrDBdTixubtMnM6J.MN0xM8\n' \ | ||
42 | '' '' | ||
43 | testing 'cryptpw sha256 rounds=99999 implicit' \ | ||
44 | 'cryptpw QWErty \$5\$rounds=99999\$123456789012345678901234567890' \ | ||
45 | '$5$rounds=99999$1234567890123456$aYellycJGZM6AKyVzaQsSrDBdTixubtMnM6J.MN0xM8\n' \ | ||
46 | '' '' | ||
28 | 47 | ||
29 | testing "cryptpw sha256 rounds=99999" \ | 48 | testing 'cryptpw sha512' \ |
30 | "cryptpw -m sha256 QWErty 'rounds=99999\$123456789012345678901234567890'" \ | 49 | 'cryptpw -m sha512 QWErty 123456789012345678901234567890' \ |
31 | '$5$rounds=99999$1234567890123456$aYellycJGZM6AKyVzaQsSrDBdTixubtMnM6J.MN0xM8\n' "" "" | 50 | '$6$1234567890123456$KB7QqxFyqmJSWyQYcCuGeFukgz1bPQoipWZf7.9L7z3k8UNTXa6UikbKcUGDc2ANn7DOGmDaroxDgpK16w/RE0\n' \ |
32 | 51 | '' '' | |
33 | testing "cryptpw sha512" \ | 52 | testing 'cryptpw sha512crypt' \ |
34 | "cryptpw -m sha512 QWErty '123456789012345678901234567890'" \ | 53 | 'cryptpw -m sha512crypt QWErty 123456789012345678901234567890' \ |
35 | '$6$1234567890123456$KB7QqxFyqmJSWyQYcCuGeFukgz1bPQoipWZf7.9L7z3k8UNTXa6UikbKcUGDc2ANn7DOGmDaroxDgpK16w/RE0\n' "" "" | 54 | '$6$1234567890123456$KB7QqxFyqmJSWyQYcCuGeFukgz1bPQoipWZf7.9L7z3k8UNTXa6UikbKcUGDc2ANn7DOGmDaroxDgpK16w/RE0\n' \ |
55 | '' '' | ||
56 | testing 'cryptpw sha512 rounds=99999' \ | ||
57 | 'cryptpw -m sha512 QWErty rounds=99999\$123456789012345678901234567890' \ | ||
58 | '$6$rounds=99999$1234567890123456$BfF6gD6ZjUmwawH5QaAglYAxtU./yvsz0fcQ464l49aMI2DZW3j5ri28CrxK7riPWNpLuUpfaIdY751SBYKUH.\n' \ | ||
59 | '' '' | ||
60 | SKIP= | ||
36 | 61 | ||
37 | testing "cryptpw sha512 rounds=99999" \ | 62 | optional USE_BB_CRYPT_YES |
38 | "cryptpw -m sha512 QWErty 'rounds=99999\$123456789012345678901234567890'" \ | 63 | testing 'cryptpw yescrypt' \ |
39 | '$6$rounds=99999$1234567890123456$BfF6gD6ZjUmwawH5QaAglYAxtU./yvsz0fcQ464l49aMI2DZW3j5ri28CrxK7riPWNpLuUpfaIdY751SBYKUH.\n' "" "" | 64 | 'cryptpw -m yescrypt qweRTY123@-+ j9T\$123456789012345678901234' \ |
65 | '$y$j9T$123456789012345678901234$AKxw5OX/T4jD.v./IW.5tE/j7izNjw06fg3OvH1LsN9\n' \ | ||
66 | '' '' | ||
67 | testing 'cryptpw yescrypt with non-standard N=2048 instead of 4096 (j8T instead of j9T)' \ | ||
68 | 'cryptpw -m yescrypt qweRTY123@-+ j8T\$123456789012345678901234' \ | ||
69 | '$y$j8T$123456789012345678901234$JQUUfopCxlfZNE8f.THJwbOkhy.XtB3GIjo9HUVioWB\n' \ | ||
70 | '' '' | ||
71 | # mkpasswd-5.6.2 allows short salts for yescrypt | ||
72 | # ...but there is a catch. Not all of them. | ||
73 | # The "partial" (not fitting in whole bytes) ascii64-encoded salt | ||
74 | # is a special case. For example, "$zzz" would not even work in upstream. | ||
75 | testing 'cryptpw yescrypt with empty salt' \ | ||
76 | 'cryptpw -m yescrypt qweRTY123@-+ j9T\$' \ | ||
77 | '$y$j9T$$hpeksL94GXNRwnA00L3c8WFy0khFAUbCpBSak.N3Bp.\n' \ | ||
78 | '' '' | ||
79 | testing 'cryptpw yescrypt with 3-char salt' \ | ||
80 | 'cryptpw -m yescrypt qweRTY123@-+ j9T\$123' \ | ||
81 | '$y$j9T$123$A34DMIGUbUIo3bjx66Wtk2IFoREMIw6d49it25KQh2D\n' \ | ||
82 | '' '' | ||
83 | # "." is not allowed in mkpasswd-5.6.2 | ||
84 | # .................................... | ||
85 | # ".." is decoded into one zero byte (not two) | ||
86 | testing 'cryptpw yescrypt with 2-char salt ".."' \ | ||
87 | 'cryptpw -m yescrypt qweRTY123@-+ j9T\$..' \ | ||
88 | '$y$j9T$..$yVHeOayxOGg6cHL3.dg10u7T.qSgySfLN3uhSVSLNn/\n' \ | ||
89 | '' '' | ||
90 | # "..." is decoded into two zero bytes (not three, not one) | ||
91 | testing 'cryptpw yescrypt with 3-char salt "..."' \ | ||
92 | 'cryptpw -m yescrypt qweRTY123@-+ j9T\$...' \ | ||
93 | '$y$j9T$...$xHvJ5USZ7hFyXYbOijtEOMfZRS23cWIxu2eIBXRymA5\n' \ | ||
94 | '' '' | ||
95 | # "...." is decoded into three zero bytes (no surprises here) | ||
96 | testing 'cryptpw yescrypt with 4-char salt "...."' \ | ||
97 | 'cryptpw -m yescrypt qweRTY123@-+ j9T\$....' \ | ||
98 | '$y$j9T$....$wOnauYL2/NEtr6YQi9pi8AtV7L57sEbVOAnWJIcP9q2\n' \ | ||
99 | '' '' | ||
100 | # 84 chars = 21 4-char blocks which decode into 21*3 = 63 bytes. | ||
101 | # The last byte of the maximum allowed salt size has to come from an incomplete | ||
102 | # char block. E.g. "z/" encodes byte 0x7f. "z1" is 0xff. | ||
103 | # Anything larger (e.g. "z2") is an error (it encodes 0x13f). | ||
104 | testing 'cryptpw yescrypt with 86-char salt (max size)' \ | ||
105 | 'cryptpw -m yescrypt qweRTY123@-+ j9T\$123456789012345678901234567890123456789012345678901234567890123456789012345678901234z/' \ | ||
106 | '$y$j9T$123456789012345678901234567890123456789012345678901234567890123456789012345678901234z/$Exxe8IoPXiddFsqj7iqCanRf8FyquAoB0/uceLmLjG.\n' \ | ||
107 | '' '' | ||
108 | testing 'cryptpw yescrypt implicit' \ | ||
109 | 'cryptpw qweRTY123@-+ \$y\$j9T\$123456789012345678901234' \ | ||
110 | '$y$j9T$123456789012345678901234$AKxw5OX/T4jD.v./IW.5tE/j7izNjw06fg3OvH1LsN9\n' \ | ||
111 | '' '' | ||
40 | SKIP= | 112 | SKIP= |
41 | 113 | ||
42 | exit $FAILCOUNT | 114 | exit $FAILCOUNT |
diff --git a/testsuite/diff.tests b/testsuite/diff.tests index 0ced0f248..ee0567a80 100755 --- a/testsuite/diff.tests +++ b/testsuite/diff.tests | |||
@@ -123,6 +123,69 @@ testing "diff always takes context from old file" \ | |||
123 | "abc\na c\ndef\n" \ | 123 | "abc\na c\ndef\n" \ |
124 | "a c\n" | 124 | "a c\n" |
125 | 125 | ||
126 | optional PLATFORM_MINGW32 LONG_OPTS | ||
127 | testing "diff LF line endings" \ | ||
128 | 'diff -u - input' \ | ||
129 | "\ | ||
130 | --- - | ||
131 | +++ input | ||
132 | @@ -1,4 +1,4 @@ | ||
133 | a | ||
134 | b | ||
135 | +c | ||
136 | d | ||
137 | -e | ||
138 | " \ | ||
139 | "a\nb\nc\nd\n" \ | ||
140 | "a\nb\nd\ne\n" | ||
141 | |||
142 | testing "diff --binary LF line endings" \ | ||
143 | 'diff --binary -u - input' \ | ||
144 | "\ | ||
145 | --- - | ||
146 | +++ input | ||
147 | @@ -1,4 +1,4 @@ | ||
148 | a | ||
149 | b | ||
150 | +c | ||
151 | d | ||
152 | -e | ||
153 | " \ | ||
154 | "a\nb\nc\nd\n" \ | ||
155 | "a\nb\nd\ne\n" | ||
156 | |||
157 | testing "diff CRLF line endings" \ | ||
158 | 'diff -u - input' \ | ||
159 | "\ | ||
160 | --- - | ||
161 | +++ input | ||
162 | @@ -1,4 +1,4 @@ | ||
163 | a | ||
164 | b | ||
165 | +c | ||
166 | d | ||
167 | -e | ||
168 | " \ | ||
169 | "a\r\nb\r\nc\r\nd\r\n" \ | ||
170 | "a\r\nb\r\nd\r\ne\r\n" | ||
171 | |||
172 | testing "diff --binary CRLF line endings" \ | ||
173 | 'diff --binary -u - input' \ | ||
174 | "\ | ||
175 | --- - | ||
176 | +++ input | ||
177 | @@ -1,4 +1,4 @@ | ||
178 | a | ||
179 | b | ||
180 | +c | ||
181 | d | ||
182 | -e | ||
183 | " \ | ||
184 | "a\r\nb\r\nc\r\nd\r\n" \ | ||
185 | "a\r\nb\r\nd\r\ne\r\n" | ||
186 | |||
187 | SKIP= | ||
188 | |||
126 | # testing "test name" "commands" "expected result" "file input" "stdin" | 189 | # testing "test name" "commands" "expected result" "file input" "stdin" |
127 | 190 | ||
128 | # clean up | 191 | # clean up |
diff --git a/testsuite/env.tests b/testsuite/env.tests new file mode 100755 index 000000000..8b810e44b --- /dev/null +++ b/testsuite/env.tests | |||
@@ -0,0 +1,71 @@ | |||
1 | #!/bin/sh | ||
2 | # Copyright 2022 by Ron Yorston | ||
3 | # Licensed under GPLv2, see file LICENSE in this source tree. | ||
4 | |||
5 | . ./testing.sh | ||
6 | |||
7 | # testing "test name" "commands" "expected result" "file input" "stdin" | ||
8 | |||
9 | optional PLATFORM_MINGW32 | ||
10 | # Not so much a test of 'env' as of whether environment variables | ||
11 | # (or the lack thereof) are correctly passed to child processes. | ||
12 | testing "environment variables 1a" \ | ||
13 | "V=set env sh -c 'env | grep ^V='" \ | ||
14 | "V=set | ||
15 | " "" "" | ||
16 | |||
17 | testing "environment variables 1b" \ | ||
18 | "V= env sh -c 'env | grep ^V='" \ | ||
19 | "V= | ||
20 | " "" "" | ||
21 | |||
22 | testing "environment variables 1c" \ | ||
23 | "env sh -c 'env | grep ^V='" \ | ||
24 | "" "" "" | ||
25 | |||
26 | testing "environment variables 2a" \ | ||
27 | "V=set sh -c 'env | grep ^V='" \ | ||
28 | "V=set | ||
29 | " "" "" | ||
30 | |||
31 | testing "environment variables 2b" \ | ||
32 | "V= sh -c 'env | grep ^V='" \ | ||
33 | "V= | ||
34 | " "" "" | ||
35 | |||
36 | testing "environment variables 2c" \ | ||
37 | "sh -c 'env | grep ^V='" \ | ||
38 | "" "" "" | ||
39 | |||
40 | testing "environment variables 3a" \ | ||
41 | "V=set env sh -c 'echo \${V-unset}'" \ | ||
42 | "set | ||
43 | " "" "" | ||
44 | |||
45 | testing "environment variables 3b" \ | ||
46 | "V= env sh -c 'echo \${V-unset}'" \ | ||
47 | " | ||
48 | " "" "" | ||
49 | |||
50 | testing "environment variables 3c" \ | ||
51 | "env sh -c 'echo \${V-unset}'" \ | ||
52 | "unset | ||
53 | " "" "" | ||
54 | |||
55 | testing "environment variables 4a" \ | ||
56 | "V=set sh -c 'echo \${V-unset}'" \ | ||
57 | "set | ||
58 | " "" "" | ||
59 | |||
60 | testing "environment variables 4b" \ | ||
61 | "V= sh -c 'echo \${V-unset}'" \ | ||
62 | " | ||
63 | " "" "" | ||
64 | |||
65 | testing "environment variables 4c" \ | ||
66 | "sh -c 'echo \${V-unset}'" \ | ||
67 | "unset | ||
68 | " "" "" | ||
69 | SKIP= | ||
70 | |||
71 | exit $FAILCOUNT | ||
diff --git a/testsuite/hexdump.tests b/testsuite/hexdump.tests index 517ec508b..b2f6a2201 100755 --- a/testsuite/hexdump.tests +++ b/testsuite/hexdump.tests | |||
@@ -5,6 +5,17 @@ | |||
5 | 5 | ||
6 | . ./testing.sh | 6 | . ./testing.sh |
7 | 7 | ||
8 | input=\ | ||
9 | "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"\ | ||
10 | "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"\ | ||
11 | "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"\ | ||
12 | "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"\ | ||
13 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | ||
14 | |||
15 | little_endian=false | ||
16 | { printf '\0\1' | hexdump -d | grep -q 256; } && little_endian=true | ||
17 | readonly little_endian | ||
18 | |||
8 | # testing "description" "command" "result" "infile" "stdin" | 19 | # testing "description" "command" "result" "infile" "stdin" |
9 | testing 'hexdump -C with four NULs' \ | 20 | testing 'hexdump -C with four NULs' \ |
10 | 'hexdump -C' \ | 21 | 'hexdump -C' \ |
@@ -43,12 +54,7 @@ testing "hexdump -e %3_u" \ | |||
43 | 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f | 54 | 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f |
44 | f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff | 55 | f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff |
45 | " \ | 56 | " \ |
46 | "" \ | 57 | "" "$input" |
47 | "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"\ | ||
48 | "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"\ | ||
49 | "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"\ | ||
50 | "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"\ | ||
51 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"\ | ||
52 | 58 | ||
53 | testing "hexdump -e /1 %d" \ | 59 | testing "hexdump -e /1 %d" \ |
54 | "hexdump -e '16/1 \" %4d\" \"\n\"'" \ | 60 | "hexdump -e '16/1 \" %4d\" \"\n\"'" \ |
@@ -59,33 +65,74 @@ testing "hexdump -e /1 %d" \ | |||
59 | -128 -127 -126 -125 -124 -123 -122 -121 -120 -119 -118 -117 -116 -115 -114 -113 | 65 | -128 -127 -126 -125 -124 -123 -122 -121 -120 -119 -118 -117 -116 -115 -114 -113 |
60 | -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 | 66 | -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 |
61 | " \ | 67 | " \ |
62 | "" \ | 68 | "" "$input" |
63 | "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"\ | ||
64 | "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"\ | ||
65 | "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"\ | ||
66 | "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"\ | ||
67 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"\ | ||
68 | 69 | ||
69 | testing "hexdump -e /2 %d" \ | 70 | $little_endian || SKIP=1 |
70 | "hexdump -e '8/2 \" %6d\" \"\n\"'" \ | 71 | testing "hexdump -e /2 %d (little endian)" \ |
71 | "\ | 72 | "hexdump -e '8/2 \" %6d\" \"\n\"'" \ |
73 | "\ | ||
72 | 256 770 1284 1798 2312 2826 3340 3854 | 74 | 256 770 1284 1798 2312 2826 3340 3854 |
73 | 4368 4882 5396 5910 6424 6938 7452 7966 | 75 | 4368 4882 5396 5910 6424 6938 7452 7966 |
74 | 29040 29554 30068 30582 31096 31610 32124 32638 | 76 | 29040 29554 30068 30582 31096 31610 32124 32638 |
75 | -32384 -31870 -31356 -30842 -30328 -29814 -29300 -28786 | 77 | -32384 -31870 -31356 -30842 -30328 -29814 -29300 -28786 |
76 | -3600 -3086 -2572 -2058 -1544 -1030 -516 -2 | 78 | -3600 -3086 -2572 -2058 -1544 -1030 -516 -2 |
77 | " \ | 79 | " \ |
78 | "" \ | 80 | "" "$input" |
79 | "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"\ | 81 | SKIP= |
80 | "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"\ | 82 | |
81 | "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"\ | 83 | $little_endian && SKIP=1 |
82 | "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"\ | 84 | testing "hexdump -e /2 %d (big endian)" \ |
83 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"\ | 85 | "hexdump -e '8/2 \" %6d\" \"\n\"'" \ |
86 | "\ | ||
87 | 1 515 1029 1543 2057 2571 3085 3599 | ||
88 | 4113 4627 5141 5655 6169 6683 7197 7711 | ||
89 | 28785 29299 29813 30327 30841 31355 31869 32383 | ||
90 | -32639 -32125 -31611 -31097 -30583 -30069 -29555 -29041 | ||
91 | -3855 -3341 -2827 -2313 -1799 -1285 -771 -257 | ||
92 | " \ | ||
93 | "" "$input" | ||
94 | SKIP= | ||
84 | 95 | ||
85 | testing "hexdump -n4 -e '\"%u\"'" \ | 96 | $little_endian || SKIP=1 |
97 | testing "hexdump -e /2 %x (little endian)" \ | ||
98 | "hexdump -e '8/2 \" %6x\" \"\n\"'" \ | ||
99 | "\ | ||
100 | 100 302 504 706 908 b0a d0c f0e | ||
101 | 1110 1312 1514 1716 1918 1b1a 1d1c 1f1e | ||
102 | 7170 7372 7574 7776 7978 7b7a 7d7c 7f7e | ||
103 | 8180 8382 8584 8786 8988 8b8a 8d8c 8f8e | ||
104 | f1f0 f3f2 f5f4 f7f6 f9f8 fbfa fdfc fffe | ||
105 | " \ | ||
106 | "" "$input" | ||
107 | SKIP= | ||
108 | |||
109 | $little_endian && SKIP=1 | ||
110 | testing "hexdump -e /2 %x (big endian)" \ | ||
111 | "hexdump -e '8/2 \" %6x\" \"\n\"'" \ | ||
112 | "\ | ||
113 | 1 203 405 607 809 a0b c0d e0f | ||
114 | 1011 1213 1415 1617 1819 1a1b 1c1d 1e1f | ||
115 | 7071 7273 7475 7677 7879 7a7b 7c7d 7e7f | ||
116 | 8081 8283 8485 8687 8889 8a8b 8c8d 8e8f | ||
117 | f0f1 f2f3 f4f5 f6f7 f8f9 fafb fcfd feff | ||
118 | " \ | ||
119 | "" "$input" | ||
120 | SKIP= | ||
121 | |||
122 | $little_endian || SKIP=1 | ||
123 | testing "hexdump -n4 -e '\"%u\"' (little endian)" \ | ||
86 | "hexdump -n4 -e '\"%u\"'" \ | 124 | "hexdump -n4 -e '\"%u\"'" \ |
87 | "12345678" \ | 125 | "12345678" \ |
88 | "" \ | 126 | "" \ |
89 | "\x4e\x61\xbc\x00AAAA" | 127 | "\x4e\x61\xbc\x00AAAA" |
128 | SKIP= | ||
129 | |||
130 | $little_endian && SKIP=1 | ||
131 | testing "hexdump -n4 -e '\"%u\"' (big endian)" \ | ||
132 | "hexdump -n4 -e '\"%u\"'" \ | ||
133 | "1315027968" \ | ||
134 | "" \ | ||
135 | "\x4e\x61\xbc\x00AAAA" | ||
136 | SKIP= | ||
90 | 137 | ||
91 | exit $FAILCOUNT | 138 | exit $FAILCOUNT |
diff --git a/testsuite/make.tests b/testsuite/make.tests new file mode 100755 index 000000000..fabdbe45c --- /dev/null +++ b/testsuite/make.tests | |||
@@ -0,0 +1,805 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | . ./testing.sh | ||
4 | unset MAKEFLAGS | ||
5 | rm -rf make.tempdir | ||
6 | |||
7 | # testing "test name" "command" "expected result" "file input" "stdin" | ||
8 | |||
9 | testing "make basic makefile" \ | ||
10 | "make -f -" "target\n" "" ' | ||
11 | target: | ||
12 | @echo target | ||
13 | ' | ||
14 | |||
15 | testing "make .DEFAULT rule for prerequisite" \ | ||
16 | "make -f - 2>/dev/null" "source\n" "" ' | ||
17 | .DEFAULT: | ||
18 | @echo $@ | ||
19 | target: source | ||
20 | ' | ||
21 | |||
22 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
23 | touch target.xyz | ||
24 | testing "make empty command overrides inference rule" \ | ||
25 | "make -f - target 2>/dev/null" "" "" ' | ||
26 | .SUFFIXES: .xyz | ||
27 | .xyz: | ||
28 | @echo xyz | ||
29 | target: ; | ||
30 | ' | ||
31 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
32 | |||
33 | # Macros should be expanded before suffix substitution. The suffixes | ||
34 | # can be obtained by macro expansion. | ||
35 | testing "make macro expansion and suffix substitution" \ | ||
36 | "make -f -" "src1.o src2.o\n" "" ' | ||
37 | DOTC = .c | ||
38 | DOTO = .o | ||
39 | SRC1 = src1.c | ||
40 | SRCS = $(SRC1) src2.c | ||
41 | target: | ||
42 | @echo $(SRCS:$(DOTC)=$(DOTO)) | ||
43 | ' | ||
44 | |||
45 | # Indeed, everything after the <colon> can be obtained by macro | ||
46 | # macro expansion. | ||
47 | testing "make macro expansion and suffix substitution 2" \ | ||
48 | "make -f -" "src1.o src2.o\n" "" ' | ||
49 | DOTS = .c=.o | ||
50 | SRC1 = src1.c | ||
51 | SRCS = $(SRC1) src2.c | ||
52 | target: | ||
53 | @echo $(SRCS:$(DOTS)) | ||
54 | ' | ||
55 | |||
56 | # It should be possible for an inference rule to determine that a | ||
57 | # prerequisite can be created using an explicit rule. | ||
58 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
59 | testing "make inference rule with explicit rule for prerequisite" \ | ||
60 | "make -f -" "touch x.p\ncat x.p >x.q\n" "" ' | ||
61 | .SUFFIXES: .p .q | ||
62 | x.q: | ||
63 | x.p: | ||
64 | touch $@ | ||
65 | .p.q: | ||
66 | cat $< >$@ | ||
67 | ' | ||
68 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
69 | |||
70 | # Austin Group defect report 875 clarifies certain aspects of the | ||
71 | # behaviour of inference rules. Study of this resulted in a number | ||
72 | # of changes to pdpmake, though this test passed anyway. | ||
73 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
74 | touch test.j test.k | ||
75 | testing "make proper handling of inference rules 1" \ | ||
76 | "make -f -" \ | ||
77 | ".j.l\n" "" ' | ||
78 | .SUFFIXES: .j .k .l | ||
79 | .j.l: | ||
80 | @echo .j.l | ||
81 | .k.l: | ||
82 | @echo .k.l | ||
83 | test.l: test.k | ||
84 | test.j: | ||
85 | test.k: | ||
86 | ' | ||
87 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
88 | |||
89 | # Check that single-suffix inference rules work. | ||
90 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
91 | touch test.sh | ||
92 | testing "make single-suffix inference rule works" \ | ||
93 | "make -f - -s; echo $?" \ | ||
94 | "0\n" "" ' | ||
95 | test: | ||
96 | ' | ||
97 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
98 | |||
99 | # There was a bug where the failure of a build command didn't result | ||
100 | # in make returning a non-zero exit status. | ||
101 | testing "make return error if command fails" \ | ||
102 | "make -f - >/dev/null 2>&1; test \$? -gt 0 && echo OK" "OK\n" "" ' | ||
103 | target: | ||
104 | @exit 42 | ||
105 | ' | ||
106 | |||
107 | # An equal sign in a command on a target rule was detected as a | ||
108 | # macro assignment. | ||
109 | testing "make equal sign in inline command" \ | ||
110 | "make -f -" "a = a\n" "" ' | ||
111 | a = a | ||
112 | target:;@echo a = $(a) | ||
113 | ' | ||
114 | |||
115 | # Ensure an inline command on a target rule can be detected even if | ||
116 | # the semicolon is obfuscated. | ||
117 | testing "make equal sign in obfuscated inline command" \ | ||
118 | "make -f -" "a = a\n" "" ' | ||
119 | a = a | ||
120 | semi = ; | ||
121 | target:$(semi)@echo a = $(a) | ||
122 | ' | ||
123 | |||
124 | # When a build command fails and the '-k' option has been provided | ||
125 | # (continue execution on error) no further commands should be executed | ||
126 | # for the current target. | ||
127 | testing "make failure of build command with -k" \ | ||
128 | "make -k -f - 2>/dev/null" "OK\n" "" ' | ||
129 | all: bar baz | ||
130 | bar: | ||
131 | @echo OK | ||
132 | @false | ||
133 | @echo Not reached | ||
134 | baz: | ||
135 | @: | ||
136 | ' | ||
137 | # Build commands with a '+' prefix are executed even with the -q option. | ||
138 | testing "make execute build command with + prefix and -q" \ | ||
139 | "make -q -f - 2>/dev/null" "OK\n" "" ' | ||
140 | all: bar | ||
141 | bar: | ||
142 | @+echo OK | ||
143 | ' | ||
144 | |||
145 | # The -t option touches files that are out-of-date unless the target | ||
146 | # has no commands or they're already up-to-date. | ||
147 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
148 | touch baz | ||
149 | testing "make check -t option" \ | ||
150 | "make -t -f - 2>/dev/null" "touch bar\n" "" ' | ||
151 | all: foo bar baz | ||
152 | foo: | ||
153 | bar: | ||
154 | @echo bar | ||
155 | baz: | ||
156 | @echo baz | ||
157 | ' | ||
158 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
159 | |||
160 | # Build commands with a '+' prefix are executed even with the -t option. | ||
161 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
162 | testing "make execute build command with + prefix and -t" \ | ||
163 | "make -t -f - 2>/dev/null" "OK\n" "" ' | ||
164 | all: bar | ||
165 | bar: | ||
166 | @+echo OK | ||
167 | ' | ||
168 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
169 | |||
170 | # A macro created using ::= remembers it's of type immediate-expansion. | ||
171 | # Immediate expansion also occurs when += is used to append to such a macro. | ||
172 | testing "make appending to immediate-expansion macro" \ | ||
173 | "make -f -" \ | ||
174 | "hello 1 2 3\nhello 4 4\n" "" ' | ||
175 | world = 1 | ||
176 | hello ::= hello $(world) | ||
177 | world = 2 | ||
178 | hello += $(world) | ||
179 | world = 3 | ||
180 | hello += $(world) | ||
181 | world = 4 | ||
182 | |||
183 | world = 1 | ||
184 | reset ::= hello $(world) | ||
185 | world = 2 | ||
186 | # No longer immediate-expansion | ||
187 | reset = hello $(world) | ||
188 | world = 3 | ||
189 | reset += $(world) | ||
190 | world = 4 | ||
191 | |||
192 | target: | ||
193 | @echo $(hello) | ||
194 | @echo $(reset) | ||
195 | ' | ||
196 | |||
197 | # Since GNU make and bmake interpret := macro assignments differently, | ||
198 | # POSIX has ::= for the GNU variant and :::= for BSD. | ||
199 | testing "make different styles of := macro assignment" \ | ||
200 | "make -f -" \ | ||
201 | '65 a a $A\n' "" ' | ||
202 | A = a | ||
203 | GNU ::= $A | ||
204 | BSD1 :::= $A | ||
205 | BSD2 :::= $$A | ||
206 | A = 65 | ||
207 | |||
208 | target: | ||
209 | @echo '\''$(A) $(GNU) $(BSD1) $(BSD2)'\'' | ||
210 | ' | ||
211 | |||
212 | # Similar to the above but for macro assignments on the command line. | ||
213 | # POSIX has ::= for the GNU variant and :::= for BSD. | ||
214 | testing "make := macro assignment on command line" \ | ||
215 | "make -f - A=a 'GNU::=\$A' 'BSD1:::=\$A' 'BSD2:::=\$\$A' A=65" \ | ||
216 | '65 a a $A\n' "" ' | ||
217 | target: | ||
218 | @echo '\''$(A) $(GNU) $(BSD1) $(BSD2)'\'' | ||
219 | ' | ||
220 | |||
221 | # basic pattern macro expansion | ||
222 | testing "make basic pattern macro expansion" \ | ||
223 | "make -f -" \ | ||
224 | "obj/util.o obj/main.o\n" "" ' | ||
225 | SRC = src/util.c src/main.c | ||
226 | OBJ = $(SRC:src/%.c=obj/%.o) | ||
227 | |||
228 | target: | ||
229 | @echo $(OBJ) | ||
230 | ' | ||
231 | |||
232 | # pattern macro expansion; match any value | ||
233 | testing "make pattern macro expansion; match any value" \ | ||
234 | "make -f -" \ | ||
235 | "any_value.o\n" "" ' | ||
236 | SRC = any_value | ||
237 | OBJ = $(SRC:%=%.o) | ||
238 | |||
239 | target: | ||
240 | @echo $(OBJ) | ||
241 | ' | ||
242 | |||
243 | # pattern macro expansion with empty rvalue | ||
244 | testing "make pattern macro expansion with empty rvalue" \ | ||
245 | "make -f -" \ | ||
246 | "\n" "" ' | ||
247 | SRC = util.c main.c | ||
248 | OBJ = $(SRC:%.c=) | ||
249 | |||
250 | target: | ||
251 | @echo $(OBJ) | ||
252 | ' | ||
253 | |||
254 | # pattern macro expansion with multiple <percent> in rvalue | ||
255 | # POSIX requires the first <percent> to be expanded, others | ||
256 | # may or may not be expanded. Permit either case. | ||
257 | testing "make pattern macro expansion with multiple <percent> in rvalue" \ | ||
258 | "make -f - | sed 's/mainmainmain/main%%/'" \ | ||
259 | "main%%\n" "" ' | ||
260 | SRC = main.c | ||
261 | OBJ = $(SRC:%.c=%%%) | ||
262 | |||
263 | target: | ||
264 | @echo $(OBJ) | ||
265 | ' | ||
266 | |||
267 | # pattern macro expansion; zero match | ||
268 | testing "make pattern macro expansion; zero match" \ | ||
269 | "make -f -" \ | ||
270 | "nsnp\n" "" ' | ||
271 | WORD = osop | ||
272 | REPL = $(WORD:os%op=ns%np) | ||
273 | |||
274 | target: | ||
275 | @echo $(REPL) | ||
276 | ' | ||
277 | |||
278 | # Check that MAKE will contain argv[0], e.g make in this case | ||
279 | testing "make basic MAKE macro expansion" \ | ||
280 | "make -f -" \ | ||
281 | "make\n" "" ' | ||
282 | target: | ||
283 | @echo $(MAKE) | ||
284 | ' | ||
285 | |||
286 | # Check that MAKE defined as environment variable will overwrite default MAKE | ||
287 | testing "make MAKE macro expansion; overwrite with env macro" \ | ||
288 | "MAKE=hello make -f -" \ | ||
289 | "hello\n" "" ' | ||
290 | target: | ||
291 | @echo $(MAKE) | ||
292 | ' | ||
293 | |||
294 | # Check that MAKE defined on the command-line will overwrite MAKE defined in | ||
295 | # Makefile | ||
296 | testing "make MAKE macro expansion; overwrite with command-line macro" \ | ||
297 | "make -f - MAKE=hello" \ | ||
298 | "hello\n" "" ' | ||
299 | MAKE = test | ||
300 | |||
301 | target: | ||
302 | @echo $(MAKE) | ||
303 | ' | ||
304 | |||
305 | # POSIX draft states that if make was invoked using relative path, MAKE must | ||
306 | # contain absolute path, not just argv[0] | ||
307 | testing "make MAKE macro expansion; turn relative path into absolute" \ | ||
308 | "../runtest-tempdir-links/make -f -" \ | ||
309 | "ok\n" "" ' | ||
310 | target: | ||
311 | @test -e "$(MAKE)" && test "$(MAKE)" = "$$(env which make)" && echo ok | ||
312 | ' | ||
313 | |||
314 | # $? contains prerequisites newer than target, file2 in this case | ||
315 | # $^ has all prerequisites, file1 and file2 | ||
316 | touch -t 202206171200 file1 | ||
317 | touch -t 202206171201 target | ||
318 | touch -t 202206171202 file2 | ||
319 | testing "make compare \$? and \$^ internal macros" \ | ||
320 | "make -f -" \ | ||
321 | "file2\nfile1 file2\n" "" ' | ||
322 | target: file1 file2 | ||
323 | @echo $? | ||
324 | @echo $^ | ||
325 | ' | ||
326 | rm -f target file1 file2 | ||
327 | |||
328 | # Phony targets are executed (once) even if a matching file exists. | ||
329 | # A .PHONY target with no prerequisites is ignored. | ||
330 | touch -t 202206171201 target | ||
331 | testing "make phony target" \ | ||
332 | "make -f -" \ | ||
333 | "phony\n" "" ' | ||
334 | .PHONY: target | ||
335 | .PHONY: | ||
336 | target: | ||
337 | @echo phony | ||
338 | ' | ||
339 | rm -f target | ||
340 | |||
341 | # Phony targets aren't touched with -t | ||
342 | testing "make phony target not touched" \ | ||
343 | "make -t -f - >/dev/null && test -f target && echo target" \ | ||
344 | "" "" ' | ||
345 | .PHONY: target | ||
346 | target: | ||
347 | @: | ||
348 | ' | ||
349 | rm -f target | ||
350 | |||
351 | # Include files are created or brought up-to-date | ||
352 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
353 | testing "make create include file" \ | ||
354 | "make -f -" \ | ||
355 | "made\n" "" ' | ||
356 | target: | ||
357 | @echo $(VAR) | ||
358 | mk: | ||
359 | @echo "VAR = made" >mk | ||
360 | include mk | ||
361 | ' | ||
362 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
363 | |||
364 | # Include files are created or brought up-to-date even when the -n | ||
365 | # option is given. | ||
366 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
367 | testing "make create include file even with -n" \ | ||
368 | "make -n -f -" \ | ||
369 | "echo made\n" "" ' | ||
370 | target: | ||
371 | @echo $(VAR) | ||
372 | mk: | ||
373 | @echo "VAR = made" >mk | ||
374 | include mk | ||
375 | ' | ||
376 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
377 | |||
378 | # Failure to create an include file isn't an error. (Provided the | ||
379 | # include line is ignoring non-existent files.) | ||
380 | testing "make failure to create include file is OK" \ | ||
381 | "make -f -" \ | ||
382 | "OK\n" "" ' | ||
383 | target: | ||
384 | @echo OK | ||
385 | mk: | ||
386 | @: | ||
387 | -include mk | ||
388 | ' | ||
389 | |||
390 | # $^ skips duplicate prerequisites, $+ doesn't | ||
391 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
392 | touch file1 file2 file3 | ||
393 | testing "make skip duplicate entries in \$^ but not \$+" \ | ||
394 | "make -f -" \ | ||
395 | "file1 file2 file3\nfile1 file2 file2 file3 file3\n" "" ' | ||
396 | target: file1 file2 file2 file3 file3 | ||
397 | @echo $^ | ||
398 | @echo $+ | ||
399 | ' | ||
400 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
401 | |||
402 | # Assign the output of a shell command to a macro. | ||
403 | testing "make shell assignment" \ | ||
404 | "make -f -" \ | ||
405 | "1 2 3 4\n" "" ' | ||
406 | hello != echo 1; echo 2; echo 3; echo; echo | ||
407 | |||
408 | target: | ||
409 | @echo "$(hello) 4" | ||
410 | ' | ||
411 | |||
412 | # Nested macro expansion is allowed. This should be compatible | ||
413 | # with other implementations. | ||
414 | testing "make nested macro expansion" \ | ||
415 | "make -f -" "0 bc\n1 d\n2\n3\n4 bcd\n5 bcd\n" "" ' | ||
416 | a = b | ||
417 | b = c | ||
418 | c = d | ||
419 | $(a:.q=.v)$(b:.z=.v) = bc | ||
420 | bcd = bcd | ||
421 | target: | ||
422 | @echo 0 $(bc) | ||
423 | @echo 1 $($($(a))) | ||
424 | @echo 2 $($(a) $(b) $(c)) | ||
425 | @echo 3 $($a $b $c) | ||
426 | @echo 4 $($(a)$(b)$(c)) | ||
427 | @echo 5 $($a$b$c) | ||
428 | ' | ||
429 | |||
430 | # .WAIT is allowed as a prerequisite. Since parallel builds aren't | ||
431 | # implemented it doesn't have any effect. | ||
432 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
433 | touch file1 file2 | ||
434 | testing "make .WAIT is allowed as a prerequisite" \ | ||
435 | "make -f -" \ | ||
436 | "file1 file2\n" "" ' | ||
437 | target: file1 .WAIT file2 | ||
438 | @echo $? | ||
439 | ' | ||
440 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
441 | |||
442 | # Escaped newlines inside macro expansions in commands get different | ||
443 | # treatment than those outside. In POSIX 2017 the output is 'a b ab'. | ||
444 | testing "make replace escaped NL in macro in command with space" \ | ||
445 | "make -f -" \ | ||
446 | "a b a b\n" "" ' | ||
447 | M=word | ||
448 | N=${M:word=a\\ | ||
449 | b} | ||
450 | target: | ||
451 | @echo ${N} ${M:word=a\\ | ||
452 | b} | ||
453 | ' | ||
454 | |||
455 | # The CURDIR macro is supported in POSIX 2024. | ||
456 | testing "make CURDIR macro" \ | ||
457 | "make -f -" \ | ||
458 | "OK\n" "" ' | ||
459 | target: | ||
460 | @test "$(CURDIR)" = "$$(pwd -P)" && echo OK | ||
461 | ' | ||
462 | # The CURDIR environment variable doesn't affect the macro | ||
463 | export CURDIR=/you/are/here | ||
464 | testing "make CURDIR macro not affected by environment" \ | ||
465 | "make -f -" \ | ||
466 | "OK\n" "" ' | ||
467 | target: | ||
468 | @test "$(CURDIR)" != "/you/are/here" && echo OK | ||
469 | ' | ||
470 | |||
471 | # The -e option makes the CURDIR macro match the environment | ||
472 | testing "make with -e CURDIR macro is affected by the environment" \ | ||
473 | "make -e -f -" \ | ||
474 | "/you/are/here\n" "" ' | ||
475 | target: | ||
476 | @echo $(CURDIR) | ||
477 | ' | ||
478 | unset CURDIR | ||
479 | |||
480 | # The fix for an equal sign in an inline command on a target rule broke | ||
481 | # a complex chain of macro assignments generated by autotools. | ||
482 | testing "make complex chain of macro assignments" \ | ||
483 | "make -f -" "flag 1\n" "" ' | ||
484 | FLAG_ = $(FLAG_$(VALUE)) | ||
485 | FLAG_0 = flag 0 | ||
486 | FLAG_1 = flag 1 | ||
487 | MYFLAG = $(FLAG_$(VALUE)) | ||
488 | VALUE = 1 | ||
489 | |||
490 | target: | ||
491 | @echo $(MYFLAG) | ||
492 | ' | ||
493 | |||
494 | # POSIX 2024 permits additional characters in macro and target names | ||
495 | testing "make allow - and / in target names, - in macro names" \ | ||
496 | "make -f -" \ | ||
497 | "/hello\nhel-lo\nmac-ro\n" "" ' | ||
498 | target: ./hello hel-lo | ||
499 | @echo $(mac-ro) | ||
500 | ./hello: | ||
501 | @echo /hello | ||
502 | hel-lo: | ||
503 | @echo hel-lo | ||
504 | mac-ro = mac-ro | ||
505 | ' | ||
506 | |||
507 | testing "make double-colon rule" \ | ||
508 | "make -f -" "target1\ntarget2\n" "" ' | ||
509 | target:: | ||
510 | @echo target1 | ||
511 | target:: | ||
512 | @echo target2 | ||
513 | ' | ||
514 | |||
515 | # There was a bug whereby the modification time of a file created by | ||
516 | # double-colon rules wasn't correctly updated. This test checks that | ||
517 | # the bug is now fixed. | ||
518 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
519 | touch -t 202206171200 file1 | ||
520 | touch -t 202206171201 intermediate | ||
521 | touch -t 202206171202 target | ||
522 | touch -t 202206171203 file2 | ||
523 | testing "make target depends on prerequisite updated by double-colon rule" \ | ||
524 | "make -f -" \ | ||
525 | "file2\n" "" ' | ||
526 | target: intermediate | ||
527 | @cat intermediate | ||
528 | intermediate:: file1 | ||
529 | @echo file1 >>intermediate | ||
530 | intermediate:: file2 | ||
531 | @echo file2 >>intermediate | ||
532 | ' | ||
533 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
534 | |||
535 | # Use chained inference rules to determine prerequisites. | ||
536 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
537 | touch target.p | ||
538 | testing "make chained inference rules" \ | ||
539 | "make -s -f - target.s" \ | ||
540 | "target.q\ntarget.r\ntarget.s\n" "" ' | ||
541 | .SUFFIXES: .p .q .r .s | ||
542 | .p.q: | ||
543 | @cp $< $*.q | ||
544 | @echo $*.q | ||
545 | .q.r: | ||
546 | @cp $< $*.r | ||
547 | @echo $*.r | ||
548 | .r.s: | ||
549 | @cp $< $*.s | ||
550 | @echo $*.s | ||
551 | ' | ||
552 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
553 | |||
554 | # Suffixes with multiple periods are supported | ||
555 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
556 | touch x.c.c | ||
557 | testing "make support multi-period suffixes" \ | ||
558 | "make -f -" "cat x.c.c >x.o.o\nx\n" "" ' | ||
559 | .SUFFIXES: .c.c .o.o | ||
560 | x.o.o: | ||
561 | .c.c.o.o: | ||
562 | cat $< >$@ | ||
563 | @echo $* | ||
564 | ' | ||
565 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
566 | |||
567 | # Suffixes with no periods are supported | ||
568 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
569 | touch filex | ||
570 | testing "make support suffixes without any periods" \ | ||
571 | "make -f -" "cp filex fileh\nfile\ncp filex filez\nfile\n" "" ' | ||
572 | .SUFFIXES: x h z | ||
573 | all: fileh filez | ||
574 | fileh: | ||
575 | filez: filex | ||
576 | cp filex filez | ||
577 | @echo $* | ||
578 | xh: | ||
579 | cp $< $@ | ||
580 | @echo $* | ||
581 | ' | ||
582 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
583 | |||
584 | # make supports *, ? and [] wildcards in targets and prerequisites | ||
585 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
586 | touch -t 202206171201 t1a t2aa t3b | ||
587 | touch s1a s2aa s3b | ||
588 | testing "make expand wildcards in filenames" \ | ||
589 | "make -f - t1a t2aa t3b" \ | ||
590 | "t1a s1a s2aa s3b\nt2aa s1a s2aa s3b\nt3b s1a s2aa s3b\n" "" ' | ||
591 | t1? t2* t3[abc]: s1? s2* s3[abc] | ||
592 | @echo $@ $? | ||
593 | ' | ||
594 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
595 | |||
596 | # A '#' character in a macro expansion doesn't start a comment | ||
597 | testing "make hash in macro expansion isn't a comment" \ | ||
598 | "make -f -" \ | ||
599 | ": hash # hash\n" "" ' | ||
600 | HASH = hash | ||
601 | hash = $(HASH:hash=#) | ||
602 | target: | ||
603 | : hash $(hash) hash | ||
604 | ' | ||
605 | |||
606 | # A '#' character can be escaped with a backslash | ||
607 | testing "make backslash-escaped hash isn't a comment" \ | ||
608 | "make -f -" \ | ||
609 | ": hash # hash\n" "" ' | ||
610 | hash = \\# | ||
611 | target: | ||
612 | : hash $(hash) hash | ||
613 | ' | ||
614 | |||
615 | # A '#' character in a command line doesn't start a comment | ||
616 | testing "make hash in command line isn't a comment" \ | ||
617 | "make -f -" \ | ||
618 | ": hash # hash\n" "" ' | ||
619 | target: | ||
620 | : hash # hash | ||
621 | ' | ||
622 | |||
623 | # Austin Group defect report 875 (mentioned above) actually used | ||
624 | # suffixes '.a .b .c'. This doesn't matter in POSIX mode but it | ||
625 | # caused a failure (now fixed) when chained inference rules were | ||
626 | # allowed. The '.a.c' and the built-in '.c.a' inference rules | ||
627 | # resulted in a loop. | ||
628 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
629 | touch test.a test.b | ||
630 | testing "make proper handling of inference rules 2" \ | ||
631 | "make -f -" \ | ||
632 | ".a.c\n" "" ' | ||
633 | .SUFFIXES: .a .b .c | ||
634 | .a.c: | ||
635 | @echo .a.c | ||
636 | .b.c: | ||
637 | @echo .b.c | ||
638 | test.c: test.b | ||
639 | test.a: | ||
640 | test.b: | ||
641 | ' | ||
642 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
643 | |||
644 | # Don't use the shell -e option when running commands. | ||
645 | testing "make no shell -e option when running commands" \ | ||
646 | "make -f -" "OK\n" "" ' | ||
647 | target: | ||
648 | @false; echo OK | ||
649 | ' | ||
650 | |||
651 | # Macros and targets may be mixed on the command line | ||
652 | testing "make allow mixed macros and targets" \ | ||
653 | "make -f - FOO=foo foo BAR=bar bar" "foo\nbar\nfoo\nbar\n" "" ' | ||
654 | foo: | ||
655 | @echo $(FOO) | ||
656 | @echo $(BAR) | ||
657 | bar: | ||
658 | @echo $(FOO) | ||
659 | @echo $(BAR) | ||
660 | ' | ||
661 | |||
662 | # $* and $< are supported for target rules | ||
663 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
664 | touch src.c src.h | ||
665 | testing 'make support $* and $< for target rules' \ | ||
666 | "make -f -" "src.c src.h\nsrc.o\nsrc\nsrc.c\n" "" ' | ||
667 | src.o: src.c src.h | ||
668 | @echo "$?" | ||
669 | @echo "$@" | ||
670 | @echo "$*" | ||
671 | @echo "$<" | ||
672 | ' | ||
673 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
674 | |||
675 | # ifeq/ifneq conditionals are supported | ||
676 | testing 'make support ifeq and ifneq conditionals' \ | ||
677 | "make -f -" "A OK\nB OK\n" "" ' | ||
678 | A = a | ||
679 | B = b | ||
680 | target: | ||
681 | ifeq ($(A),a) | ||
682 | @echo A OK | ||
683 | else | ||
684 | @echo A not OK | ||
685 | endif | ||
686 | ifneq "a" "$B" | ||
687 | @echo B OK | ||
688 | endif | ||
689 | ' | ||
690 | |||
691 | # An empty original suffix indicates that every word should have | ||
692 | # the new suffix added. If neither suffix is provided the words | ||
693 | # remain unchanged. | ||
694 | testing "make macro expansion and suffix substitution 3" \ | ||
695 | "make -f -" "src1.c src2.c\nsrc1 src2\n" "" ' | ||
696 | SRCS = src1 src2 | ||
697 | target: | ||
698 | @echo $(SRCS:=.c) | ||
699 | @echo $(SRCS:=) | ||
700 | ' | ||
701 | |||
702 | # Skip duplicate entries in $? and $^ | ||
703 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
704 | touch -t 202206171200 file1 file3 | ||
705 | touch -t 202206171201 target | ||
706 | touch -t 202206171202 file2 | ||
707 | testing "make skip duplicate entries in \$? and \$^" \ | ||
708 | "make -f -" \ | ||
709 | "file2\nfile1 file2 file3\n" "" ' | ||
710 | target: file1 file2 file2 file3 file3 | ||
711 | @echo $? | ||
712 | @echo $^ | ||
713 | ' | ||
714 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
715 | |||
716 | # Skip duplicate entries in $? and $^, with each double-colon rule | ||
717 | # handled separately | ||
718 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
719 | touch -t 202206171200 file1 file3 | ||
720 | touch -t 202206171201 target | ||
721 | touch -t 202206171202 file2 | ||
722 | testing "make skip duplicate entries: double-colon rules" \ | ||
723 | "make -f -" \ | ||
724 | "file2\nfile1 file3 file2\nfile2\nfile2 file3\n" "" ' | ||
725 | target:: file1 file3 file1 file2 file3 | ||
726 | @echo $? | ||
727 | @echo $^ | ||
728 | target:: file2 file3 file3 | ||
729 | @echo $? | ||
730 | @echo $^ | ||
731 | ' | ||
732 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
733 | |||
734 | # Skip duplicate entries in $? and $^, with each double-colon rule | ||
735 | # handled separately. No prerequisites out-of-date in the first. | ||
736 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
737 | touch -t 202206171200 file1 file3 | ||
738 | touch -t 202206171201 target | ||
739 | touch -t 202206171202 file2 | ||
740 | testing "make skip duplicate entries: double-colon rules, only second invoked" \ | ||
741 | "make -f -" \ | ||
742 | "file2\nfile2 file3\n" "" ' | ||
743 | target:: file1 file3 file1 file3 | ||
744 | @echo $? | ||
745 | @echo $^ | ||
746 | target:: file2 file3 file3 | ||
747 | @echo $? | ||
748 | @echo $^ | ||
749 | ' | ||
750 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
751 | |||
752 | # .DEFAULT rules with no commands or some prerequisites are ignored. | ||
753 | # .DEFAULT rules with commands can be redefined. | ||
754 | testing "make: .DEFAULT rule" \ | ||
755 | "make -f - default" "default2\n" "" ' | ||
756 | .DEFAULT: ignored | ||
757 | .DEFAULT: | ||
758 | @echo default1 | ||
759 | .DEFAULT: | ||
760 | @echo default2 | ||
761 | target: | ||
762 | ' | ||
763 | |||
764 | testing "make: double-colon rule" \ | ||
765 | "make -f -" "target1\ntarget2\n" "" ' | ||
766 | target:: | ||
767 | @echo target1 | ||
768 | target:: | ||
769 | @echo target2 | ||
770 | ' | ||
771 | |||
772 | # Double-colon rules didn't work properly if their target was phony: | ||
773 | # - they didn't ignore the presence of a file matching the target name; | ||
774 | # - they were also invoked as if they were a single-colon rule. | ||
775 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
776 | touch -t 202206171200 file1 | ||
777 | touch -t 202206171201 target | ||
778 | testing "make phony target of double-colon rule" \ | ||
779 | "make -f - 2>&1" \ | ||
780 | "unconditional\nconditional\n" "" ' | ||
781 | .PHONY: target | ||
782 | target:: | ||
783 | @echo unconditional | ||
784 | target:: file1 | ||
785 | @echo conditional | ||
786 | file1: | ||
787 | @touch file1 | ||
788 | ' | ||
789 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
790 | |||
791 | # GNU make and BSD make don't allow the use of inference rules | ||
792 | # for phony targets. In POSIX mode the output is "phony.xyz\n". | ||
793 | mkdir make.tempdir && cd make.tempdir || exit 1 | ||
794 | touch phony.xyz | ||
795 | testing "make don't use inference rule for phony target" \ | ||
796 | "make -f -" "make: nothing to be done for phony\n" "" ' | ||
797 | .PHONY: phony | ||
798 | .SUFFIXES: .xyz | ||
799 | .xyz: | ||
800 | @echo $< | ||
801 | phony: | ||
802 | ' | ||
803 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | ||
804 | |||
805 | exit $FAILCOUNT | ||
diff --git a/testsuite/od.tests b/testsuite/od.tests index 4f245a7e8..c863bf2e8 100755 --- a/testsuite/od.tests +++ b/testsuite/od.tests | |||
@@ -61,7 +61,8 @@ testing "od -a (DESKTOP)" \ | |||
61 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" | 61 | "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" |
62 | SKIP= | 62 | SKIP= |
63 | 63 | ||
64 | testing "od -B" \ | 64 | $little_endian || SKIP=1 |
65 | testing "od -B (little-endian)" \ | ||
65 | "od -B" \ | 66 | "od -B" \ |
66 | "\ | 67 | "\ |
67 | 0000000 001001 005003 041101 177103 | 68 | 0000000 001001 005003 041101 177103 |
@@ -70,6 +71,16 @@ testing "od -B" \ | |||
70 | "" "$input" | 71 | "" "$input" |
71 | SKIP= | 72 | SKIP= |
72 | 73 | ||
74 | $little_endian && SKIP=1 | ||
75 | testing "od -B (big-endian)" \ | ||
76 | "od -B" \ | ||
77 | "\ | ||
78 | 0000000 000402 001412 040502 041776 | ||
79 | 0000010 | ||
80 | " \ | ||
81 | "" "$input" | ||
82 | SKIP= | ||
83 | |||
73 | $little_endian || SKIP=1 | 84 | $little_endian || SKIP=1 |
74 | testing "od -o (little-endian)" \ | 85 | testing "od -o (little-endian)" \ |
75 | "od -o" \ | 86 | "od -o" \ |
diff --git a/testsuite/runtest b/testsuite/runtest index 44f9cd1a1..adbcb1178 100755 --- a/testsuite/runtest +++ b/testsuite/runtest | |||
@@ -99,6 +99,20 @@ if [ x"$1" = x"-v" ]; then | |||
99 | shift | 99 | shift |
100 | fi | 100 | fi |
101 | 101 | ||
102 | if [ -f "$bindir/busybox.exe" ]; then | ||
103 | suffix=".exe" | ||
104 | lnflag="" | ||
105 | |||
106 | # Some tests require /bin/echo and /bin/true exist | ||
107 | test ! -d /tmp && mkdir /tmp | ||
108 | test ! -d /bin && mkdir /bin | ||
109 | test ! -f /bin/echo.exe && cp "$bindir/busybox.exe" /bin/echo.exe | ||
110 | test ! -f /bin/true.exe && cp "$bindir/busybox.exe" /bin/true.exe | ||
111 | else | ||
112 | suffix="" | ||
113 | lnflag="-s" | ||
114 | fi | ||
115 | |||
102 | implemented=$( | 116 | implemented=$( |
103 | printf "busybox " # always implemented | 117 | printf "busybox " # always implemented |
104 | "$bindir/busybox" 2>&1 | | 118 | "$bindir/busybox" 2>&1 | |
@@ -128,7 +142,7 @@ for i in $implemented; do | |||
128 | # Note: if $LINKSDIR/applet exists, we do not overwrite it. | 142 | # Note: if $LINKSDIR/applet exists, we do not overwrite it. |
129 | # Useful if one wants to run tests against a standard utility, | 143 | # Useful if one wants to run tests against a standard utility, |
130 | # not an applet. | 144 | # not an applet. |
131 | ln -s "$bindir/busybox" "$LINKSDIR/$i" 2>/dev/null | 145 | ln $lnflag "$bindir/busybox$suffix" "$LINKSDIR/$i$suffix" 2>/dev/null |
132 | done | 146 | done |
133 | 147 | ||
134 | # Set up option flags so tests can be selective. | 148 | # Set up option flags so tests can be selective. |
@@ -146,7 +160,7 @@ for applet in $applets; do | |||
146 | 160 | ||
147 | # Is this a new-style test? | 161 | # Is this a new-style test? |
148 | if [ -f "$applet.tests" ]; then | 162 | if [ -f "$applet.tests" ]; then |
149 | if [ ! -e "$LINKSDIR/$applet" ]; then | 163 | if [ ! -e "$LINKSDIR/$applet$suffix" ]; then |
150 | # (avoiding bash'ism "${applet:0:4}") | 164 | # (avoiding bash'ism "${applet:0:4}") |
151 | if ! echo "$applet" | grep "^all_" >/dev/null; then | 165 | if ! echo "$applet" | grep "^all_" >/dev/null; then |
152 | echo "SKIPPED: $applet (not built)" | 166 | echo "SKIPPED: $applet (not built)" |
diff --git a/testsuite/sh.tests b/testsuite/sh.tests new file mode 100755 index 000000000..0eccf20bc --- /dev/null +++ b/testsuite/sh.tests | |||
@@ -0,0 +1,118 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Test sh scripts | ||
4 | # | ||
5 | # Copyright 2019 by STMicroelectronics | ||
6 | # Licensed under GPLv2, see file LICENSE in this source tree. | ||
7 | |||
8 | . ./testing.sh | ||
9 | |||
10 | test -f "$bindir/.config" && . "$bindir/.config" | ||
11 | |||
12 | # testing "test name" "options" "expected result" "file input" "stdin" | ||
13 | |||
14 | optional PLATFORM_MINGW32 | ||
15 | # Test case | ||
16 | testing "shebang" \ | ||
17 | "uudecode; sh -c './shebang.sh'; echo \$?" \ | ||
18 | "Hello world | ||
19 | 0 | ||
20 | " \ | ||
21 | "" "\ | ||
22 | begin-base64 755 shebang.sh | ||
23 | IyEvYmluL3NoCmVjaG8gIkhlbGxvIHdvcmxkIgo= | ||
24 | ==== | ||
25 | " | ||
26 | rm -f shebang.sh | ||
27 | |||
28 | # Test case | ||
29 | testing "shebang with whitespace" \ | ||
30 | "uudecode; sh -c './shebang_trailing_space.sh'; echo \$?" \ | ||
31 | "Hello world | ||
32 | 0 | ||
33 | " \ | ||
34 | "" "\ | ||
35 | begin-base64 755 shebang_trailing_space.sh | ||
36 | IyEvYmluL3NoIAplY2hvICJIZWxsbyB3b3JsZCIK | ||
37 | ==== | ||
38 | " | ||
39 | rm -f shebang_trailing_space.sh | ||
40 | |||
41 | # Test case | ||
42 | testing "shebang with argument" \ | ||
43 | "uudecode; sh -c './shebang_argument.sh'; echo \$?" \ | ||
44 | "Hello world | ||
45 | 0 | ||
46 | " \ | ||
47 | "" "\ | ||
48 | begin-base64 755 shebang_argument.sh | ||
49 | IyEvYmluL3NoIC0KZWNobyAiSGVsbG8gd29ybGQiCg== | ||
50 | ==== | ||
51 | " | ||
52 | rm -f shebang_argument.sh | ||
53 | |||
54 | # Test case | ||
55 | testing "shebang with leading whitespace and argument" \ | ||
56 | "uudecode; sh -c './shebang_leading_space_argument.sh'; echo \$?" \ | ||
57 | "Hello world | ||
58 | 0 | ||
59 | " \ | ||
60 | "" "\ | ||
61 | begin-base64 755 shebang_leading_space_argument.sh | ||
62 | IyEvYmluL3NoICAtCmVjaG8gIkhlbGxvIHdvcmxkIgo= | ||
63 | ==== | ||
64 | " | ||
65 | rm -f shebang_leading_space_argument.sh | ||
66 | |||
67 | # Test case | ||
68 | testing "shebang with argument and trailing whitespace" \ | ||
69 | "uudecode; sh -c './shebang_argument_trailing_space.sh'; echo \$?" \ | ||
70 | "Hello world | ||
71 | 0 | ||
72 | " \ | ||
73 | "" "\ | ||
74 | begin-base64 755 shebang_argument_trailing_space.sh | ||
75 | IyEvYmluL3NoIC0gCmVjaG8gIkhlbGxvIHdvcmxkIgo= | ||
76 | ==== | ||
77 | " | ||
78 | rm -f shebang_argument_trailing_space.sh | ||
79 | |||
80 | # Test case | ||
81 | testing "shebang with leading whitespace, argument and trailing whitespace" \ | ||
82 | "uudecode; sh -c './shebang_leading_argument_trailing_space.sh'; echo \$?" \ | ||
83 | "Hello world | ||
84 | 0 | ||
85 | " \ | ||
86 | "" "\ | ||
87 | begin-base64 755 shebang_leading_argument_trailing_space.sh | ||
88 | IyEvYmluL3NoICAtIAplY2hvICJIZWxsbyB3b3JsZCIK | ||
89 | ==== | ||
90 | " | ||
91 | rm -f shebang_leading_argument_trailing_space.sh | ||
92 | |||
93 | testing "sh remove CRs from string being evaluated" \ | ||
94 | "sh -c \"$(printf 'set -e\r\necho Hello world\r\n')\"" \ | ||
95 | "Hello world\n" "" "" | ||
96 | |||
97 | testing "sh preserve lone CRs during field splitting" \ | ||
98 | "sh input" \ | ||
99 | "Hello\r world\n" "echo \$(printf \"Hello\\\\r\\\\r\\\\nworld\\\\r\\\\n\")" "" | ||
100 | |||
101 | testing "sh read with CRLF" \ | ||
102 | "printf '1 2\\r\\n' | { read var; printf \"\${var}\\\\n\"; }" \ | ||
103 | "1 2\n" "" "" | ||
104 | |||
105 | testing "sh read with CR" \ | ||
106 | "printf '1\\r2\\r\\n' | { read var; printf \"\${var}\\\\n\"; }" \ | ||
107 | "1\r2\n" "" "" | ||
108 | |||
109 | testing "sh read with \\CRLF" \ | ||
110 | "printf '1\\\\\r\\n2\\r\\n' | { read var; printf \"\${var}\\\\n\"; }" \ | ||
111 | "12\n" "" "" | ||
112 | |||
113 | testing "sh read with \\CR" \ | ||
114 | "printf '1\\\\\r2\\r\\n' | { read var; printf \"\${var}\\\\n\"; }" \ | ||
115 | "1\r2\n" "" "" | ||
116 | SKIP= | ||
117 | |||
118 | exit $FAILCOUNT | ||
diff --git a/testsuite/wget/wget-handles-https b/testsuite/wget/wget-handles-https new file mode 100644 index 000000000..11915f42f --- /dev/null +++ b/testsuite/wget/wget-handles-https | |||
@@ -0,0 +1,4 @@ | |||
1 | test x"$SKIP_INTERNET_TESTS" != x"" && exit | ||
2 | |||
3 | busybox wget -q -O foo https://www.google.com/ | ||
4 | test -s foo | ||