diff options
author | David Leonard <d+busybox@adaptive-enterprises.com> | 2023-05-11 23:49:58 +1000 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-05-25 15:32:03 +0200 |
commit | 64bdd7566c21cb53cb4c384ed52845106529e55f (patch) | |
tree | ee58fcdc0b1d2c2747653a2a398136125b9e3811 | |
parent | 2bda790fd14adb80820643198bb1e96e4be73571 (diff) | |
download | busybox-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-x | testsuite/od.tests | 210 | ||||
-rw-r--r-- | testsuite/testing.sh | 10 |
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 | ||
9 | input="$(printf '\001\002\003\nABC\xfe')" | ||
10 | |||
11 | le=false | ||
12 | { printf '\0\1' | od -i | grep -q 256; } && le=true | ||
13 | readonly le | ||
14 | |||
15 | optional !DESKTOP | ||
16 | testing "od -a (!DESKTOP)" \ | ||
17 | "od -a" \ | ||
18 | "\ | ||
19 | 0000000 soh stx etx lf A B C fe | ||
20 | 0000010 | ||
21 | " \ | ||
22 | "" "$input" | ||
23 | SKIP= | ||
24 | |||
25 | optional !DESKTOP | ||
26 | testing "od -B (!DESKTOP)" \ | ||
27 | "od -B" \ | ||
28 | "\ | ||
29 | 0000000 001001 005003 041101 177103 | ||
30 | 0000010 | ||
31 | " \ | ||
32 | "" "$input" | ||
33 | SKIP= | ||
34 | |||
35 | optional !DESKTOP | ||
36 | $le || SKIP=1 | ||
37 | testing "od -o (!DESKTOP little-endian)" \ | ||
38 | "od -o" \ | ||
39 | "\ | ||
40 | 0000000 001001 005003 041101 177103 | ||
41 | 0000010 | ||
42 | " \ | ||
43 | "" "$input" | ||
44 | SKIP= | ||
45 | |||
46 | optional !DESKTOP | ||
47 | testing "od -b (!DESKTOP)" \ | ||
48 | "od -b" \ | ||
49 | "\ | ||
50 | 0000000 001 002 003 012 101 102 103 376 | ||
51 | 0000010 | ||
52 | " \ | ||
53 | "" "$input" | ||
54 | SKIP= | ||
55 | |||
56 | optional !DESKTOP | ||
57 | testing "od -c (!DESKTOP)" \ | ||
58 | "od -c" \ | ||
59 | "\ | ||
60 | 0000000 001 002 003 \\\\n A B C 376 | ||
61 | 0000010 | ||
62 | " \ | ||
63 | "" "$input" | ||
64 | SKIP= | ||
65 | |||
66 | optional !DESKTOP | ||
67 | $le || SKIP=1 | ||
68 | testing "od -d (!DESKTOP little-endian)" \ | ||
69 | "od -d" \ | ||
70 | "\ | ||
71 | 0000000 00513 02563 16961 65091 | ||
72 | 0000010 | ||
73 | " \ | ||
74 | "" "$input" | ||
75 | SKIP= | ||
76 | |||
77 | optional !DESKTOP | ||
78 | $le || SKIP=1 | ||
79 | testing "od -D (!DESKTOP little-endian)" \ | ||
80 | "od -D" \ | ||
81 | "\ | ||
82 | 0000000 0167969281 4265820737 | ||
83 | 0000010 | ||
84 | " \ | ||
85 | "" "$input" | ||
86 | SKIP= | ||
87 | |||
88 | optional !DESKTOP | ||
89 | $le || SKIP=1 | ||
90 | testing "od -e (!DESKTOP little-endian)" \ | ||
91 | "od -e" \ | ||
92 | "\ | ||
93 | 0000000 -1.61218556514036e+300 | ||
94 | 0000010 | ||
95 | " \ | ||
96 | "" "$input" | ||
97 | SKIP= | ||
98 | |||
99 | optional !DESKTOP | ||
100 | $le || SKIP=1 | ||
101 | testing "od -F (!DESKTOP little-endian)" \ | ||
102 | "od -F" \ | ||
103 | "\ | ||
104 | 0000000 -1.61218556514036e+300 | ||
105 | 0000010 | ||
106 | " \ | ||
107 | "" "$input" | ||
108 | |||
109 | optional !DESKTOP | ||
110 | $le || SKIP=1 | ||
111 | testing "od -f (!DESKTOP little-endian)" \ | ||
112 | "od -f" \ | ||
113 | "\ | ||
114 | 0000000 6.3077975e-33 -6.4885867e+37 | ||
115 | 0000010 | ||
116 | " \ | ||
117 | "" "$input" | ||
118 | SKIP= | ||
119 | |||
120 | optional !DESKTOP | ||
121 | $le || SKIP=1 | ||
122 | testing "od -H (!DESKTOP little-endian)" \ | ||
123 | "od -H" \ | ||
124 | "\ | ||
125 | 0000000 0a030201 fe434241 | ||
126 | 0000010 | ||
127 | " \ | ||
128 | "" "$input" | ||
129 | SKIP= | ||
130 | |||
131 | optional !DESKTOP | ||
132 | $le || SKIP=1 | ||
133 | testing "od -X (!DESKTOP little-endian)" \ | ||
134 | "od -X" \ | ||
135 | "\ | ||
136 | 0000000 0a030201 fe434241 | ||
137 | 0000010 | ||
138 | " \ | ||
139 | "" "$input" | ||
140 | SKIP= | ||
141 | |||
142 | optional !DESKTOP | ||
143 | $le || SKIP=1 | ||
144 | testing "od -h (!DESKTOP little-endian)" \ | ||
145 | "od -h" \ | ||
146 | "\ | ||
147 | 0000000 0201 0a03 4241 fe43 | ||
148 | 0000010 | ||
149 | " \ | ||
150 | "" "$input" | ||
151 | SKIP= | ||
152 | |||
153 | optional !DESKTOP | ||
154 | $le || SKIP=1 | ||
155 | testing "od -x (!DESKTOP little-endian)" \ | ||
156 | "od -x" \ | ||
157 | "\ | ||
158 | 0000000 0201 0a03 4241 fe43 | ||
159 | 0000010 | ||
160 | " \ | ||
161 | "" "$input" | ||
162 | SKIP= | ||
163 | |||
164 | optional !DESKTOP | ||
165 | $le || SKIP=1 | ||
166 | testing "od -I (!DESKTOP little-endian)" \ | ||
167 | "od -I" \ | ||
168 | "\ | ||
169 | 0000000 167969281 -29146559 | ||
170 | 0000010 | ||
171 | " \ | ||
172 | "" "$input" | ||
173 | SKIP= | ||
174 | |||
175 | optional !DESKTOP | ||
176 | $le || SKIP=1 | ||
177 | testing "od -L (!DESKTOP little-endian)" \ | ||
178 | "od -L" \ | ||
179 | "\ | ||
180 | 0000000 167969281 -29146559 | ||
181 | 0000010 | ||
182 | " \ | ||
183 | "" "$input" | ||
184 | SKIP= | ||
185 | |||
186 | optional !DESKTOP | ||
187 | $le || SKIP=1 | ||
188 | testing "od -i (!DESKTOP little-endian)" \ | ||
189 | "od -i" \ | ||
190 | "\ | ||
191 | 0000000 513 2563 16961 -445 | ||
192 | 0000010 | ||
193 | " \ | ||
194 | "" "$input" | ||
195 | SKIP= | ||
196 | |||
197 | optional !DESKTOP | ||
198 | $le || SKIP=1 | ||
199 | testing "od -O (!DESKTOP little-endian)" \ | ||
200 | "od -O" \ | ||
201 | "\ | ||
202 | 0000000 01200601001 37620641101 | ||
203 | 0000010 | ||
204 | " \ | ||
205 | "" "$input" | ||
206 | SKIP= | ||
207 | |||
208 | optional !DESKTOP | ||
209 | $le || SKIP=1 | ||
210 | testing "od -l (!DESKTOP little-endian)" \ | ||
211 | "od -l" \ | ||
212 | "\ | ||
213 | 0000000 167969281 -29146559 | ||
214 | 0000010 | ||
215 | " \ | ||
216 | "" "$input" | ||
217 | SKIP= | ||
218 | |||
9 | optional DESKTOP | 219 | optional DESKTOP |
10 | testing "od -b" \ | 220 | testing "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 | ||