busybox/testsuite/od.tests

261 lines
3.8 KiB
Text
Raw Normal View History

2008-04-14 19:50:06 +00:00
#!/bin/sh
# Copyright 2008 by Denys Vlasenko
# Licensed under GPLv2, see file LICENSE in this source tree.
2008-04-14 19:50:06 +00:00
. ./testing.sh
2008-04-14 19:50:06 +00:00
# testing "test name" "commands" "expected result" "file input" "stdin"
2008-04-14 19:50:06 +00:00
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=
$le || SKIP=1
testing "od -D (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=
$le || SKIP=1
testing "od -H (little-endian)" \
"od -H" \
"\
0000000 0a030201 fe434241
0000010
" \
"" "$input"
SKIP=
$le || SKIP=1
testing "od -X (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=
$le || SKIP=1
testing "od -i (little-endian)" \
"od -i" \
"\
0000000 167969281 -29146559
0000010
" \
"" "$input"
SKIP=
$le || SKIP=1
testing "od -O (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 -I (little-endian)" \
"od -I" \
"\
0000000 -125183517527965183
0000010
" \
"" "$input"
testing "od -L (little-endian)" \
"od -L" \
"\
0000000 -125183517527965183
0000010
" \
"" "$input"
testing "od -l (little-endian)" \
"od -l" \
"\
0000000 -125183517527965183
0000010
" \
"" "$input"
SKIP=
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
0000005
2008-04-14 19:50:06 +00:00
" \
"" "HELLO"
SKIP=
2008-04-14 19:50:06 +00: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=
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=
2008-04-14 19:50:06 +00:00
exit $FAILCOUNT