2 # Validate cksum operation
4 # Copyright (C) 2020-2023 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 printf
22 returns_
1 cksum missing || fail
=1
25 for offset
in $
(seq -1 6); do
26 env
printf $
(env
printf '\\%03o' $
(seq 0 $offset));
27 env
printf $
(env
printf '\\%03o' $
(seq 0 255));
29 } > in || framework_failure_
31 cksum in > out || fail
=1
32 printf '%s\n' '4097727897 2077 in' > exp || framework_failure_
33 compare exp out || fail
=1
35 # Make sure crc is correct for files larger than 128 bytes (4 fold pclmul)
37 env
printf $
(env
printf '\\%03o' $
(seq 0 130));
38 } > in || framework_failure_
40 cksum in > out || fail
=1
41 printf '%s\n' '3800919234 131 in' > exp || framework_failure_
42 compare exp out || fail
=1
44 # Make sure crc is correct for files larger than 32 bytes
45 # but <128 bytes (1 fold pclmul)
47 env
printf $
(env
printf '\\%03o' $
(seq 0 64));
48 } > in || framework_failure_
50 cksum in > out || fail
=1
51 printf '%s\n' '796287823 65 in' > exp || framework_failure_
52 compare exp out || fail
=1
54 # Make sure crc is still handled correctly when next 65k buffer is read
55 # (>32 bytes more than 65k)
58 } > in || framework_failure_
60 cksum in > out || fail
=1
61 printf '%s\n' '3720986905 65574 in' > exp || framework_failure_
62 compare exp out || fail
=1
64 # Make sure crc is still handled correctly when next 65k buffer is read
65 # (>=128 bytes more than 65k)
68 } > in || framework_failure_
70 cksum in > out || fail
=1
71 printf '%s\n' '4278270357 65664 in' > exp || framework_failure_
72 compare exp out || fail
=1