diff options
| author | Pádraig Brady <P@draigBrady.com> | 2025-09-04 14:42:03 +0100 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2025-09-04 14:52:21 +0100 |
| commit | a43a17f2169a3761a689035a476bf5482c4b4f7c (patch) | |
| tree | 771660a5c0d9f0d25416d4c45a847d29aa55abd2 | |
| parent | doc: NEWS: expand on the fold multi-byte enhancements (diff) | |
| download | coreutils-a43a17f2169a3761a689035a476bf5482c4b4f7c.tar.gz coreutils-a43a17f2169a3761a689035a476bf5482c4b4f7c.zip | |
tests: cksum: check more length variants
* tests/cksum/cksum-raw.sh: Adjust to non legacy naming,
and also check various length variations.
* tests/misc/read-errors.sh: Likewise.
| -rwxr-xr-x | tests/cksum/cksum-raw.sh | 39 | ||||
| -rwxr-xr-x | tests/misc/read-errors.sh | 12 |
2 files changed, 28 insertions, 23 deletions
diff --git a/tests/cksum/cksum-raw.sh b/tests/cksum/cksum-raw.sh index 83e5678a3..857dbe35c 100755 --- a/tests/cksum/cksum-raw.sh +++ b/tests/cksum/cksum-raw.sh @@ -25,30 +25,31 @@ sysv u2 crc u4 md5 x1 sha1 x1 -sha224 x1 -sha256 x1 -sha384 x1 -sha512 x1 -blake2b x1 +sha2 x1 -l224 -l256 -l384 -l512 +sha3 x1 -l224 -l256 -l384 -l512 +blake2b x1 -l8 -l256 -l512 sm3 x1 EOF date > file.in || framework_failure_ -while read algo type; do - # Binary converted back to text - cksum --raw --algorithm $algo file.in > digest.bin || fail=1 - d='digest.bin.txt' - od --endian=big -An -w1024 -t$type < digest.bin | tr -d ' ' \ - > "$d" || framework_failure_ - # Pad the bsd checksum with leading 0's, if needed. - case $algo in bsd) n=$(cat "$d"); printf '%05d\n' "$n" > "$d" ;; esac - - # Standard text output - cksum --untagged --algorithm $algo < file.in | cut -d ' ' -f1 \ - > digest.txt || fail=1 - - compare digest.txt "$d" || fail=1 +while read algo type lengths; do + : "${lengths:=-l0}" + for len in $lengths; do + # Binary converted back to text + cksum --raw -a $algo $len file.in > digest.bin || fail=1 + d='digest.bin.txt' + od --endian=big -An -w1024 -t$type < digest.bin | tr -d ' ' \ + > "$d" || framework_failure_ + # Pad the bsd checksum with leading 0's, if needed. + case $algo in bsd) n=$(cat "$d"); printf '%05d\n' "$n" > "$d" ;; esac + + # Standard text output + cksum --untagged -a $algo $len < file.in | cut -d ' ' -f1 \ + > digest.txt || fail=1 + + compare digest.txt "$d" || fail=1 + done done < digest_types # Ensure --base64 and --raw not used together diff --git a/tests/misc/read-errors.sh b/tests/misc/read-errors.sh index 1a78a7990..f491b905e 100755 --- a/tests/misc/read-errors.sh +++ b/tests/misc/read-errors.sh @@ -30,10 +30,14 @@ cksum -a crc . cksum -a crc32b . cksum -a md5 . cksum -a sha1 . -cksum -a sha224 . -cksum -a sha256 . -cksum -a sha384 . -cksum -a sha512 . +cksum -a sha2 -l 224 . +cksum -a sha2 -l 256 . +cksum -a sha2 -l 384 . +cksum -a sha2 -l 512 . +cksum -a sha3 -l 224 . +cksum -a sha3 -l 256 . +cksum -a sha3 -l 384 . +cksum -a sha3 -l 512 . cksum -a sm3 . cksum -a sysv . comm . . |
