2008-04-14 19:50:06 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright 2008 by Denys Vlasenko
|
2010-08-16 20:14:46 +02:00
|
|
|
# Licensed under GPLv2, see file LICENSE in this source tree.
|
2008-04-14 19:50:06 +00:00
|
|
|
|
2009-11-04 18:41:22 -05:00
|
|
|
. ./testing.sh
|
2008-04-14 19:50:06 +00:00
|
|
|
|
2011-05-21 17:43:06 +02:00
|
|
|
# testing "test name" "commands" "expected result" "file input" "stdin"
|
2008-04-14 19:50:06 +00:00
|
|
|
|
2023-05-11 23:49:58 +10:00
|
|
|
input="$(printf '\001\002\003\nABC\xfe')"
|
|
|
|
|
|
|
|
le=false
|
2023-05-25 17:39:28 +02:00
|
|
|
{ printf '\0\1' | od -s | grep -q 256; } && le=true
|
2023-05-11 23:49:58 +10:00
|
|
|
readonly le
|
|
|
|
|
2023-05-26 04:27:43 +02:00
|
|
|
$le || SKIP=1
|
|
|
|
testing "od (little-endian)" \
|
|
|
|
"od" \
|
|
|
|
"\
|
|
|
|
0000000 001001 005003 041101 177103
|
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
2023-05-11 23:49:58 +10:00
|
|
|
optional !DESKTOP
|
|
|
|
testing "od -a (!DESKTOP)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -a" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 soh stx etx lf A B C fe
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
2023-05-25 19:51:37 +02:00
|
|
|
# ^^^ 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=
|
2023-05-11 23:49:58 +10:00
|
|
|
|
2023-05-25 22:17:18 +02:00
|
|
|
testing "od -B" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -B" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 001001 005003 041101 177103
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-25 19:51:37 +02:00
|
|
|
testing "od -o (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -o" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 001001 005003 041101 177103
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
2023-05-25 19:51:37 +02:00
|
|
|
testing "od -b" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -b" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 001 002 003 012 101 102 103 376
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
2023-05-25 19:51:37 +02:00
|
|
|
testing "od -c" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -c" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 001 002 003 \\\\n A B C 376
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-25 19:51:37 +02:00
|
|
|
testing "od -d (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -d" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 513 2563 16961 65091
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-26 12:56:17 +02:00
|
|
|
testing "od -D (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -D" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 167969281 4265820737
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
2023-05-25 19:51:37 +02:00
|
|
|
optional !DESKTOP #DESKTOP: unrecognized option: e
|
2023-05-11 23:49:58 +10:00
|
|
|
$le || SKIP=1
|
|
|
|
testing "od -e (!DESKTOP little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -e" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 -1.61218556514036e+300
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
2023-05-25 19:51:37 +02:00
|
|
|
optional !DESKTOP #DESKTOP: unrecognized option: F
|
2023-05-11 23:49:58 +10:00
|
|
|
$le || SKIP=1
|
|
|
|
testing "od -F (!DESKTOP little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -F" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 -1.61218556514036e+300
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
2023-05-25 22:17:18 +02:00
|
|
|
SKIP=
|
2023-05-11 23:49:58 +10:00
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-25 22:17:18 +02:00
|
|
|
testing "od -f (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -f" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 6.3077975e-33 -6.4885867e+37
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-26 12:56:17 +02:00
|
|
|
testing "od -H (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -H" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 0a030201 fe434241
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-26 12:56:17 +02:00
|
|
|
testing "od -X (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -X" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 0a030201 fe434241
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-25 19:51:37 +02:00
|
|
|
testing "od -h (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -h" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 0201 0a03 4241 fe43
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-25 19:51:37 +02:00
|
|
|
testing "od -x (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -x" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 0201 0a03 4241 fe43
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-26 12:56:17 +02:00
|
|
|
testing "od -i (little-endian)" \
|
|
|
|
"od -i" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-26 12:56:17 +02:00
|
|
|
0000000 167969281 -29146559
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
$le || SKIP=1
|
2023-05-26 12:56:17 +02:00
|
|
|
testing "od -O (little-endian)" \
|
|
|
|
"od -O" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-26 12:56:17 +02:00
|
|
|
0000000 01200601001 37620641101
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
2023-05-26 12:56:17 +02:00
|
|
|
# This probably also depends on word width of the arch (what is "long"?)
|
2023-05-11 23:49:58 +10:00
|
|
|
$le || SKIP=1
|
2023-05-26 12:56:17 +02:00
|
|
|
testing "od -I (little-endian)" \
|
|
|
|
"od -I" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-26 12:56:17 +02:00
|
|
|
0000000 -125183517527965183
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
2023-05-26 12:56:17 +02:00
|
|
|
testing "od -L (little-endian)" \
|
|
|
|
"od -L" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-26 12:56:17 +02:00
|
|
|
0000000 -125183517527965183
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
2023-05-25 19:51:37 +02:00
|
|
|
testing "od -l (little-endian)" \
|
2023-05-25 23:48:13 +02:00
|
|
|
"od -l" \
|
2023-05-11 23:49:58 +10:00
|
|
|
"\
|
2023-05-25 17:39:28 +02:00
|
|
|
0000000 -125183517527965183
|
2023-05-11 23:49:58 +10:00
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "$input"
|
|
|
|
SKIP=
|
|
|
|
|
2010-05-11 03:53:57 +02:00
|
|
|
optional DESKTOP
|
2008-04-14 19:50:06 +00:00
|
|
|
testing "od -b" \
|
2008-04-14 19:56:46 +00:00
|
|
|
"od -b" \
|
2008-04-14 19:50:06 +00:00
|
|
|
"\
|
2008-04-14 19:56:46 +00:00
|
|
|
0000000 110 105 114 114 117
|
2009-07-18 16:22:26 +02:00
|
|
|
0000005
|
2008-04-14 19:50:06 +00:00
|
|
|
" \
|
|
|
|
"" "HELLO"
|
2010-05-11 03:53:57 +02:00
|
|
|
SKIP=
|
2008-04-14 19:50:06 +00:00
|
|
|
|
2017-07-19 10:43:10 +01:00
|
|
|
optional DESKTOP
|
|
|
|
testing "od -f" \
|
|
|
|
"od -f" \
|
|
|
|
"\
|
|
|
|
0000000 0.0000000e+00 0.0000000e+00
|
|
|
|
0000010
|
|
|
|
" \
|
|
|
|
"" "\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
|
|
SKIP=
|
|
|
|
|
2011-08-10 00:51:29 +02:00
|
|
|
optional DESKTOP LONG_OPTS
|
2011-05-21 17:43:06 +02:00
|
|
|
testing "od -b --traditional" \
|
|
|
|
"od -b --traditional" \
|
|
|
|
"\
|
|
|
|
0000000 110 105 114 114 117
|
|
|
|
0000005
|
|
|
|
" \
|
|
|
|
"" "HELLO"
|
|
|
|
SKIP=
|
|
|
|
|
2011-08-10 00:51:29 +02:00
|
|
|
optional DESKTOP LONG_OPTS
|
2011-05-21 17:43:06 +02:00
|
|
|
testing "od -b --traditional FILE" \
|
|
|
|
"od -b --traditional input" \
|
|
|
|
"\
|
|
|
|
0000000 110 105 114 114 117
|
|
|
|
0000005
|
|
|
|
" \
|
|
|
|
"HELLO" ""
|
|
|
|
SKIP=
|
|
|
|
|
2008-04-14 19:50:06 +00:00
|
|
|
exit $FAILCOUNT
|