tests: add test for locale decimal processing
[coreutils.git] / tests / misc / b2sum.sh
blob00dce418b6ad0d30478287fdf85b4b01bd93d228
1 #!/bin/sh
2 # 'b2sum' tests
4 # Copyright (C) 2016-2019 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_ b2sum
22 # Ensure we can --check the --tag format we produce
23 rm check.b2sum
24 for i in 'a' ' b' '*c' '44' ' '; do
25 echo "$i" > "$i"
26 for l in 0 128; do
27 b2sum -l $l --tag "$i" >> check.b2sum
28 done
29 done
30 # Note -l is inferred from the tags in the mixed format file
31 b2sum --strict -c check.b2sum || fail=1
32 # Also ensure the openssl tagged variant works
33 sed 's/ //; s/ =/=/' < check.b2sum > openssl.b2sum || framework_failure_
34 b2sum --strict -c openssl.b2sum || fail=1
36 # Ensure we can check non tagged format
37 for l in 0 128; do
38 b2sum -l $l /dev/null | tee -a check.vals > check.b2sum
39 b2sum -l $l --strict -c check.b2sum || fail=1
40 b2sum --strict -c check.b2sum || fail=1
41 done
43 # Ensure the checksum values are correct. The reference
44 # check.vals was created with the upstream SSE reference implementation.
45 b2sum -l 128 check.vals > out || fail=1
46 printf '%s\n' '796485dd32fe9b754ea5fd6c721271d9 check.vals' > exp
47 compare exp out || fail=1
49 # This would segfault from coreutils-8.26 to coreutils-8.28
50 printf '%s\n' 'BLAKE2' 'BLAKE2b' 'BLAKE2-' 'BLAKE2(' 'BLAKE2 (' > crash.check \
51 || framework_failure_
52 returns_ 1 b2sum -c crash.check || fail=1
54 Exit $fail