cp: with --no-preserve=mode ensure set-group-ID bits maintained on dirs
[coreutils.git] / tests / cksum / cksum-c.sh
blobaad626607f767c87be8d805340fee6e1f3e8b9c8
1 #!/bin/sh
2 # Validate cksum --check dynamic operation
4 # Copyright (C) 2021-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 shuf
22 shuf -i 1-10 > input || framework_failure_
24 for args in '-a sha384' '-a blake2b' '-a blake2b -l 384' '-a sm3'; do
25 cksum $args 'input' >> CHECKSUMS || fail=1
26 done
27 cksum --strict --check CHECKSUMS || fail=1
29 # Ensure leading whitespace and \ ignored
30 sed 's/^/ \\/' CHECKSUMS | cksum --strict -c || fail=1
32 # Check common signed checksums format works in non strict mode
33 cat >> signed_CHECKSUMS <<\EOF
34 -----BEGIN PGP SIGNED MESSAGE-----
35 Hash: SHA384
37 # ignored comment
38 EOF
39 cat CHECKSUMS >> signed_CHECKSUMS
40 cat >> signed_CHECKSUMS <<\EOF
41 -----BEGIN PGP SIGNATURE-----
43 # Note base64 doesn't have ambiguous delimiters in its charset
44 SHA384+BCAAdFiEEjFummQvbJuGfKhqAEWGuaUVxmjkFAmCDId0ACgkQEWGuaUVx
45 BLAKE2b/00001EuON62pTEnqrJ5lav61QxRByiuDp/6VODrRL2JWM6Stxu1Myws=
46 =AWU7
47 -----END PGP SIGNATURE-----
48 EOF
49 cksum --check signed_CHECKSUMS || fail=1
51 # Can check individual digests in a mixed file
52 cksum --check -a sm3 CHECKSUMS || fail=1
54 # Checks against older (non hex) checksum formats not supported
55 returns_ 1 cksum -a crc -c CHECKSUMS || fail=1
56 cksum -a crc 'input' > CHECKSUMS.crc || fail=1
57 returns_ 1 cksum -c CHECKSUMS.crc || fail=1
59 Exit $fail