264 lines
4.2 KiB
Bash
Executable file
264 lines
4.2 KiB
Bash
Executable file
#!/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
|
|
|
|
# NB:
|
|
# sed 's/ *$//' truncates trailing spaces.
|
|
# This needs to be fixed properly (not output them).
|
|
# For now, the tests ignore them (does not require a match).
|
|
|
|
optional !DESKTOP
|
|
testing "od -a (!DESKTOP)" \
|
|
"od -a | sed 's/ *$//'" \
|
|
"\
|
|
0000000 soh stx etx lf A B C fe
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
testing "od -B (!DESKTOP)" \
|
|
"od -B | sed 's/ *$//'" \
|
|
"\
|
|
0000000 001001 005003 041101 177103
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -o (!DESKTOP little-endian)" \
|
|
"od -o | sed 's/ *$//'" \
|
|
"\
|
|
0000000 001001 005003 041101 177103
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
testing "od -b (!DESKTOP)" \
|
|
"od -b | sed 's/ *$//'" \
|
|
"\
|
|
0000000 001 002 003 012 101 102 103 376
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
testing "od -c (!DESKTOP)" \
|
|
"od -c | sed 's/ *$//'" \
|
|
"\
|
|
0000000 001 002 003 \\\\n A B C 376
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -d (!DESKTOP little-endian)" \
|
|
"od -d | sed 's/ *$//'" \
|
|
"\
|
|
0000000 513 2563 16961 65091
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -D (!DESKTOP little-endian)" \
|
|
"od -D | sed 's/ *$//'" \
|
|
"\
|
|
0000000 167969281 4265820737
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -e (!DESKTOP little-endian)" \
|
|
"od -e | sed 's/ *$//'" \
|
|
"\
|
|
0000000 -1.61218556514036e+300
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -F (!DESKTOP little-endian)" \
|
|
"od -F | sed 's/ *$//'" \
|
|
"\
|
|
0000000 -1.61218556514036e+300
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -f (!DESKTOP little-endian)" \
|
|
"od -f | sed 's/ *$//'" \
|
|
"\
|
|
0000000 6.3077975e-33 -6.4885867e+37
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -H (!DESKTOP little-endian)" \
|
|
"od -H | sed 's/ *$//'" \
|
|
"\
|
|
0000000 0a030201 fe434241
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -X (!DESKTOP little-endian)" \
|
|
"od -X | sed 's/ *$//'" \
|
|
"\
|
|
0000000 0a030201 fe434241
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -h (!DESKTOP little-endian)" \
|
|
"od -h | sed 's/ *$//'" \
|
|
"\
|
|
0000000 0201 0a03 4241 fe43
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -x (!DESKTOP little-endian)" \
|
|
"od -x | sed 's/ *$//'" \
|
|
"\
|
|
0000000 0201 0a03 4241 fe43
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -I (!DESKTOP little-endian)" \
|
|
"od -I | sed 's/ *$//'" \
|
|
"\
|
|
0000000 -125183517527965183
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -L (!DESKTOP little-endian)" \
|
|
"od -L | sed 's/ *$//'" \
|
|
"\
|
|
0000000 -125183517527965183
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -i (!DESKTOP little-endian)" \
|
|
"od -i | sed 's/ *$//'" \
|
|
"\
|
|
0000000 167969281 -29146559
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -O (!DESKTOP little-endian)" \
|
|
"od -O | sed 's/ *$//'" \
|
|
"\
|
|
0000000 01200601001 37620641101
|
|
0000010
|
|
" \
|
|
"" "$input"
|
|
SKIP=
|
|
|
|
optional !DESKTOP
|
|
$le || SKIP=1
|
|
testing "od -l (!DESKTOP little-endian)" \
|
|
"od -l | sed 's/ *$//'" \
|
|
"\
|
|
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
|