2 # Validate cksum --raw operation
4 # Copyright (C) 2023-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
20 print_ver_
cksum date od
22 cat > digest_types
<<\EOF || framework_failure_
36 date > file.
in || framework_failure_
38 while read algo
type; do
39 # Binary converted back to text
40 cksum --raw --algorithm $algo file.
in > digest.bin || fail
=1
42 od --endian=big
-An -w1024 -t$type < digest.bin |
tr -d ' ' \
43 > "$d" || framework_failure_
44 # Pad the bsd checksum with leading 0's, if needed.
45 case $algo in bsd
) n
=$
(cat "$d"); printf '%05d\n' "$n" > "$d" ;; esac
47 # Standard text output
48 cksum --untagged --algorithm $algo < file.
in | cut
-d ' ' -f1 \
49 > digest.txt || fail
=1
51 compare digest.txt
"$d" || fail
=1
54 # Ensure --base64 and --raw not used together
55 returns_
1 cksum --base64 --raw </dev
/null || fail
=1
57 # Ensure --raw not supported with multiple files
58 returns_
1 cksum --raw /dev
/null
/dev
/null || fail
=1