summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas DAHLQUIST <niklas.dahlquist@st.com>2019-05-03 09:32:53 +0100
committerRon Yorston <rmy@pobox.com>2019-05-03 09:32:53 +0100
commitee3d2805065f09b3d5d28e3518f1351b5d1c0bf7 (patch)
tree1d509780d5b037de390d9c3d0d195316ca7f5b5c
parentec43ab469dec9b18a3393be9f51790a09f5d7948 (diff)
downloadbusybox-w32-ee3d2805065f09b3d5d28e3518f1351b5d1c0bf7.tar.gz
busybox-w32-ee3d2805065f09b3d5d28e3518f1351b5d1c0bf7.tar.bz2
busybox-w32-ee3d2805065f09b3d5d28e3518f1351b5d1c0bf7.zip
testsuite: added test cases for the shebang
Signed-off-by: Niklas DAHLQUIST <niklas.dahlquist@st.com> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com> Signed-off-by: Ron Yorston <rmy@pobox.com>
-rwxr-xr-xtestsuite/sh.tests90
1 files changed, 90 insertions, 0 deletions
diff --git a/testsuite/sh.tests b/testsuite/sh.tests
new file mode 100755
index 000000000..2a510fb25
--- /dev/null
+++ b/testsuite/sh.tests
@@ -0,0 +1,90 @@
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
10test -f "$bindir/.config" && . "$bindir/.config"
11
12# testing "test name" "options" "expected result" "file input" "stdin"
13
14# Test case
15testing "shebang" \
16 "uudecode; sh -c './shebang.sh'; echo \$?" \
17 "Hello world
180
19" \
20"" "\
21begin-base64 755 shebang.sh
22IyEvYmluL3NoCmVjaG8gIkhlbGxvIHdvcmxkIgo=
23====
24"
25rm -f shebang.sh
26
27# Test case
28testing "shebang with whitespace" \
29 "uudecode; sh -c './shebang_trailing_space.sh'; echo \$?" \
30 "Hello world
310
32" \
33"" "\
34begin-base64 755 shebang_trailing_space.sh
35IyEvYmluL3NoIAplY2hvICJIZWxsbyB3b3JsZCIK
36====
37"
38rm -f shebang_trailing_space.sh
39
40# Test case
41testing "shebang with argument" \
42 "uudecode; sh -c './shebang_argument.sh'; echo \$?" \
43 "Hello world
440
45" \
46"" "\
47begin-base64 755 shebang_argument.sh
48IyEvYmluL3NoIC0KZWNobyAiSGVsbG8gd29ybGQiCg==
49====
50"
51rm -f shebang_argument.sh
52
53# Test case
54testing "shebang with leading whitespace and argument" \
55 "uudecode; sh -c './shebang_leading_space_argument.sh'; echo \$?" \
56 "Hello world
570
58" \
59"" "\
60begin-base64 755 shebang_leading_space_argument.sh
61IyEvYmluL3NoICAtCmVjaG8gIkhlbGxvIHdvcmxkIgo=
62====
63"
64rm -f shebang_leading_space_argument.sh
65
66# Test case
67testing "shebang with argument and trailing whitespace" \
68 "uudecode; sh -c './shebang_argument_trailing_space.sh'; echo \$?" \
69 "Hello world
700
71" \
72"" "\
73begin-base64 755 shebang_argument_trailing_space.sh
74IyEvYmluL3NoIC0gCmVjaG8gIkhlbGxvIHdvcmxkIgo=
75====
76"
77rm -f shebang_argument_trailing_space.sh
78
79# Test case
80testing "shebang with leading whitespace, argument and trailing whitespace" \
81 "uudecode; sh -c './shebang_leading_argument_trailing_space.sh'; echo \$?" \
82 "Hello world
830
84" \
85"" "\
86begin-base64 755 shebang_leading_argument_trailing_space.sh
87IyEvYmluL3NoICAtIAplY2hvICJIZWxsbyB3b3JsZCIK
88====
89"
90rm -f shebang_leading_argument_trailing_space.sh