aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Leonard <d+busybox@adaptive-enterprises.com>2023-05-11 23:49:58 +1000
committerDenys Vlasenko <vda.linux@googlemail.com>2023-05-25 15:32:03 +0200
commit64bdd7566c21cb53cb4c384ed52845106529e55f (patch)
treeee58fcdc0b1d2c2747653a2a398136125b9e3811
parent2bda790fd14adb80820643198bb1e96e4be73571 (diff)
downloadbusybox-w32-64bdd7566c21cb53cb4c384ed52845106529e55f.tar.gz
busybox-w32-64bdd7566c21cb53cb4c384ed52845106529e55f.tar.bz2
busybox-w32-64bdd7566c21cb53cb4c384ed52845106529e55f.zip
od: add tests
* Added tests for od (non-DESKTOP little-endian) * Allow 'optional' to invert meaning of a config option with '!' Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-xtestsuite/od.tests210
-rw-r--r--testsuite/testing.sh10
2 files changed, 220 insertions, 0 deletions
diff --git a/testsuite/od.tests b/testsuite/od.tests
index 0880e0d2f..0b949d5f0 100755
--- a/testsuite/od.tests
+++ b/testsuite/od.tests
@@ -6,6 +6,216 @@
6 6
7# testing "test name" "commands" "expected result" "file input" "stdin" 7# testing "test name" "commands" "expected result" "file input" "stdin"
8 8
9input="$(printf '\001\002\003\nABC\xfe')"
10
11le=false
12{ printf '\0\1' | od -i | grep -q 256; } && le=true
13readonly le
14
15optional !DESKTOP
16testing "od -a (!DESKTOP)" \
17 "od -a" \
18"\
190000000 soh stx etx lf A B C fe
200000010
21" \
22 "" "$input"
23SKIP=
24
25optional !DESKTOP
26testing "od -B (!DESKTOP)" \
27 "od -B" \
28"\
290000000 001001 005003 041101 177103
300000010
31" \
32 "" "$input"
33SKIP=
34
35optional !DESKTOP
36$le || SKIP=1
37testing "od -o (!DESKTOP little-endian)" \
38 "od -o" \
39"\
400000000 001001 005003 041101 177103
410000010
42" \
43 "" "$input"
44SKIP=
45
46optional !DESKTOP
47testing "od -b (!DESKTOP)" \
48 "od -b" \
49"\
500000000 001 002 003 012 101 102 103 376
510000010
52" \
53 "" "$input"
54SKIP=
55
56optional !DESKTOP
57testing "od -c (!DESKTOP)" \
58 "od -c" \
59"\
600000000 001 002 003 \\\\n A B C 376
610000010
62" \
63 "" "$input"
64SKIP=
65
66optional !DESKTOP
67$le || SKIP=1
68testing "od -d (!DESKTOP little-endian)" \
69 "od -d" \
70"\
710000000 00513 02563 16961 65091
720000010
73" \
74 "" "$input"
75SKIP=
76
77optional !DESKTOP
78$le || SKIP=1
79testing "od -D (!DESKTOP little-endian)" \
80 "od -D" \
81"\
820000000 0167969281 4265820737
830000010
84" \
85 "" "$input"
86SKIP=
87
88optional !DESKTOP
89$le || SKIP=1
90testing "od -e (!DESKTOP little-endian)" \
91 "od -e" \
92"\
930000000 -1.61218556514036e+300
940000010
95" \
96 "" "$input"
97SKIP=
98
99optional !DESKTOP
100$le || SKIP=1
101testing "od -F (!DESKTOP little-endian)" \
102 "od -F" \
103"\
1040000000 -1.61218556514036e+300
1050000010
106" \
107 "" "$input"
108
109optional !DESKTOP
110$le || SKIP=1
111testing "od -f (!DESKTOP little-endian)" \
112 "od -f" \
113"\
1140000000 6.3077975e-33 -6.4885867e+37
1150000010
116" \
117 "" "$input"
118SKIP=
119
120optional !DESKTOP
121$le || SKIP=1
122testing "od -H (!DESKTOP little-endian)" \
123 "od -H" \
124"\
1250000000 0a030201 fe434241
1260000010
127" \
128 "" "$input"
129SKIP=
130
131optional !DESKTOP
132$le || SKIP=1
133testing "od -X (!DESKTOP little-endian)" \
134 "od -X" \
135"\
1360000000 0a030201 fe434241
1370000010
138" \
139 "" "$input"
140SKIP=
141
142optional !DESKTOP
143$le || SKIP=1
144testing "od -h (!DESKTOP little-endian)" \
145 "od -h" \
146"\
1470000000 0201 0a03 4241 fe43
1480000010
149" \
150 "" "$input"
151SKIP=
152
153optional !DESKTOP
154$le || SKIP=1
155testing "od -x (!DESKTOP little-endian)" \
156 "od -x" \
157"\
1580000000 0201 0a03 4241 fe43
1590000010
160" \
161 "" "$input"
162SKIP=
163
164optional !DESKTOP
165$le || SKIP=1
166testing "od -I (!DESKTOP little-endian)" \
167 "od -I" \
168"\
1690000000 167969281 -29146559
1700000010
171" \
172 "" "$input"
173SKIP=
174
175optional !DESKTOP
176$le || SKIP=1
177testing "od -L (!DESKTOP little-endian)" \
178 "od -L" \
179"\
1800000000 167969281 -29146559
1810000010
182" \
183 "" "$input"
184SKIP=
185
186optional !DESKTOP
187$le || SKIP=1
188testing "od -i (!DESKTOP little-endian)" \
189 "od -i" \
190"\
1910000000 513 2563 16961 -445
1920000010
193" \
194 "" "$input"
195SKIP=
196
197optional !DESKTOP
198$le || SKIP=1
199testing "od -O (!DESKTOP little-endian)" \
200 "od -O" \
201"\
2020000000 01200601001 37620641101
2030000010
204" \
205 "" "$input"
206SKIP=
207
208optional !DESKTOP
209$le || SKIP=1
210testing "od -l (!DESKTOP little-endian)" \
211 "od -l" \
212"\
2130000000 167969281 -29146559
2140000010
215" \
216 "" "$input"
217SKIP=
218
9optional DESKTOP 219optional DESKTOP
10testing "od -b" \ 220testing "od -b" \
11 "od -b" \ 221 "od -b" \
diff --git a/testsuite/testing.sh b/testsuite/testing.sh
index f5b756947..95bb46dda 100644
--- a/testsuite/testing.sh
+++ b/testsuite/testing.sh
@@ -56,11 +56,21 @@ optional()
56{ 56{
57 SKIP= 57 SKIP=
58 while test "$1"; do 58 while test "$1"; do
59 case $1 in
60 "!"*)
61 case "${OPTIONFLAGS}" in
62 *:${1#!}:*) SKIP=1; return;;
63 esac
64 shift
65 ;;
66 *)
59 case "${OPTIONFLAGS}" in 67 case "${OPTIONFLAGS}" in
60 *:$1:*) ;; 68 *:$1:*) ;;
61 *) SKIP=1; return ;; 69 *) SKIP=1; return ;;
62 esac 70 esac
63 shift 71 shift
72 ;;
73 esac
64 done 74 done
65} 75}
66 76