cp: with --no-preserve=mode ensure set-group-ID bits maintained on dirs
[coreutils.git] / tests / cksum / cksum-raw.sh
blobb83371098932710dfacdaecc41fc9d6bb56fc98e
1 #!/bin/sh
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_
23 bsd u2
24 sysv u2
25 crc u4
26 md5 x1
27 sha1 x1
28 sha224 x1
29 sha256 x1
30 sha384 x1
31 sha512 x1
32 blake2b x1
33 sm3 x1
34 EOF
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
41 d='digest.bin.txt'
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
52 done < digest_types
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
60 Exit $fail