od: align multiple -t specs
[platform/upstream/coreutils.git] / tests / misc / od-multiple-t
1 #!/bin/sh
2 # verify that multiple -t specifiers to od align well
3 # This would fail before coreutils-6.13.
4
5 # Copyright (C) 2008 Free Software Foundation, Inc.
6
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 if test "$VERBOSE" = yes; then
21   set -x
22   od --version
23 fi
24
25 . $srcdir/test-lib.sh
26
27 # Choose 48 bytes for the input, as that is lcm for 1, 2, 4, 8, 12, 16;
28 # we don't anticipate any other native object size on modern hardware.
29 seq 19 > in || framework_failure
30 test `wc -c < in` -eq 48 || framework_failure
31
32 fail=0
33
34 list='a c dC dS dI dL oC oS oI oL uC uS uI uL xC xS xI xL fF fD fL'
35 for format1 in $list; do
36   for format2 in $list; do
37     od -An -t${format1}z -t${format2}z in > out-raw || fail=1
38     linewidth=`head -n1 out-raw | wc -c`
39     linecount=`wc -l < out-raw`
40     echo $format1 $format2 `wc -c < out-raw` >> out
41     echo $format1 $format2 `expr $linewidth '*' $linecount` >> exp
42   done
43 done
44
45 compare out exp || fail=1
46
47 (exit $fail); exit $fail