blob: d6f50a206eda7da9c995d498bec507e521d75ddb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
#!/bin/sh
# Copyright 2008 by Denys Vlasenko
# Licensed under GPLv2, see file LICENSE in this source tree.
. ./testing.sh
# testing "test name" "commands" "expected result" "file input" "stdin"
input="$(printf '\001\002\003\nABC\xfe')"
le=false
{ printf '\0\1' | od -s | grep -q 256; } && le=true
readonly le
$le || SKIP=1
testing "od (little-endian)" \
"od" \
"\
0000000 001001 005003 041101 177103
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP
testing "od -a (!DESKTOP)" \
"od -a" \
"\
0000000 soh stx etx lf A B C fe
0000010
" \
"" "$input"
SKIP=
# ^^^ a bit incorrect handling of ctrl/high bytes.
# vvv this output is correct.
optional DESKTOP
testing "od -a (DESKTOP)" \
"od -a" \
"\
0000000 soh stx etx nl A B C ~
0000010
" \
"" "$input"
SKIP=
testing "od -B" \
"od -B" \
"\
0000000 001001 005003 041101 177103
0000010
" \
"" "$input"
SKIP=
$le || SKIP=1
testing "od -o (little-endian)" \
"od -o" \
"\
0000000 001001 005003 041101 177103
0000010
" \
"" "$input"
SKIP=
testing "od -b" \
"od -b" \
"\
0000000 001 002 003 012 101 102 103 376
0000010
" \
"" "$input"
SKIP=
testing "od -c" \
"od -c" \
"\
0000000 001 002 003 \\\\n A B C 376
0000010
" \
"" "$input"
SKIP=
$le || SKIP=1
testing "od -d (little-endian)" \
"od -d" \
"\
0000000 513 2563 16961 65091
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP #DESKTOP: unrecognized option: D
$le || SKIP=1
testing "od -D (!DESKTOP little-endian)" \
"od -D" \
"\
0000000 167969281 4265820737
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP #DESKTOP: unrecognized option: e
$le || SKIP=1
testing "od -e (!DESKTOP little-endian)" \
"od -e" \
"\
0000000 -1.61218556514036e+300
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP #DESKTOP: unrecognized option: F
$le || SKIP=1
testing "od -F (!DESKTOP little-endian)" \
"od -F" \
"\
0000000 -1.61218556514036e+300
0000010
" \
"" "$input"
SKIP=
$le || SKIP=1
testing "od -f (little-endian)" \
"od -f" \
"\
0000000 6.3077975e-33 -6.4885867e+37
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP #DESKTOP: unrecognized option: H
$le || SKIP=1
testing "od -H (!DESKTOP little-endian)" \
"od -H" \
"\
0000000 0a030201 fe434241
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP #DESKTOP: unrecognized option: X
$le || SKIP=1
testing "od -X (!DESKTOP little-endian)" \
"od -X" \
"\
0000000 0a030201 fe434241
0000010
" \
"" "$input"
SKIP=
$le || SKIP=1
testing "od -h (little-endian)" \
"od -h" \
"\
0000000 0201 0a03 4241 fe43
0000010
" \
"" "$input"
SKIP=
$le || SKIP=1
testing "od -x (little-endian)" \
"od -x" \
"\
0000000 0201 0a03 4241 fe43
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP #DESKTOP: unrecognized option: I
$le || SKIP=1
testing "od -I (!DESKTOP little-endian)" \
"od -I" \
"\
0000000 -125183517527965183
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP #DESKTOP: unrecognized option: L
$le || SKIP=1
testing "od -L (!DESKTOP little-endian)" \
"od -L" \
"\
0000000 -125183517527965183
0000010
" \
"" "$input"
SKIP=
$le || SKIP=1
testing "od -i (little-endian)" \
"od -i" \
"\
0000000 167969281 -29146559
0000010
" \
"" "$input"
SKIP=
optional !DESKTOP #DESKTOP: unrecognized option: O
$le || SKIP=1
testing "od -O (!DESKTOP little-endian)" \
"od -O" \
"\
0000000 01200601001 37620641101
0000010
" \
"" "$input"
SKIP=
# This probably also depends on word width of the arch (what is "long"?)
$le || SKIP=1
testing "od -l (little-endian)" \
"od -l" \
"\
0000000 -125183517527965183
0000010
" \
"" "$input"
SKIP=
optional DESKTOP
testing "od -b" \
"od -b" \
"\
0000000 110 105 114 114 117
0000005
" \
"" "HELLO"
SKIP=
optional DESKTOP
testing "od -f" \
"od -f" \
"\
0000000 0.0000000e+00 0.0000000e+00
0000010
" \
"" "\x00\x00\x00\x00\x00\x00\x00\x00"
SKIP=
optional DESKTOP LONG_OPTS
testing "od -b --traditional" \
"od -b --traditional" \
"\
0000000 110 105 114 114 117
0000005
" \
"" "HELLO"
SKIP=
optional DESKTOP LONG_OPTS
testing "od -b --traditional FILE" \
"od -b --traditional input" \
"\
0000000 110 105 114 114 117
0000005
" \
"HELLO" ""
SKIP=
exit $FAILCOUNT
|