tests: cksum: add incorrect data to verify --check & --strict
[coreutils.git] / tests / shred / shred-passes.sh
blob5b1e3d9f23aa62608eb39c74b782f60fa25957e0
1 #!/bin/sh
2 # Verify the operations done by shred
4 # Copyright (C) 2009-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_ shred
23 # shred a single letter, which should result in
24 # 3 random passes and a single rename.
25 printf 1 > f || framework_failure_
26 echo "\
27 shred: f: pass 1/3 (random)...
28 shred: f: pass 2/3 (random)...
29 shred: f: pass 3/3 (random)...
30 shred: f: removing
31 shred: f: renamed to 0
32 shred: f: removed" > exp || framework_failure_
34 shred -v -u f 2>out || fail=1
35 compare exp out || fail=1
38 # Likewise but for a zero length file
39 # to bypass the data passes
40 touch f || framework_failure_
41 echo "\
42 shred: f: removing
43 shred: f: renamed to 0
44 shred: f: removed" > exp || framework_failure_
46 shred -v -u f 2>out || fail=1
47 compare exp out || fail=1
50 # shred data 20 times and verify the passes used.
51 # This would consume all random data between 5.93 and 8.24 inclusive.
52 dd bs=100K count=1 if=/dev/zero | tr '\0' 'U' > Us || framework_failure_
53 printf 1 > f || framework_failure_
54 echo "\
55 shred: f: pass 1/20 (random)...
56 shred: f: pass 2/20 (ffffff)...
57 shred: f: pass 3/20 (924924)...
58 shred: f: pass 4/20 (888888)...
59 shred: f: pass 5/20 (db6db6)...
60 shred: f: pass 6/20 (777777)...
61 shred: f: pass 7/20 (492492)...
62 shred: f: pass 8/20 (bbbbbb)...
63 shred: f: pass 9/20 (555555)...
64 shred: f: pass 10/20 (aaaaaa)...
65 shred: f: pass 11/20 (random)...
66 shred: f: pass 12/20 (6db6db)...
67 shred: f: pass 13/20 (249249)...
68 shred: f: pass 14/20 (999999)...
69 shred: f: pass 15/20 (111111)...
70 shred: f: pass 16/20 (000000)...
71 shred: f: pass 17/20 (b6db6d)...
72 shred: f: pass 18/20 (eeeeee)...
73 shred: f: pass 19/20 (333333)...
74 shred: f: pass 20/20 (random)...
75 shred: f: removing
76 shred: f: renamed to 0
77 shred: f: removed" > exp || framework_failure_
79 shred -v -u -n20 -s4096 --random-source=Us f 2>out || fail=1
80 compare exp out || fail=1
82 # Trigger an issue in shred before v8.27 where single
83 # bytes in the pattern space were not initialized correctly
84 # for particular sizes, like 7,13,...
85 # This failed under both valgrind and ASAN.
86 for size in 1 2 6 7 8; do
87 touch shred.pattern.umr.size
88 shred -n4 -s$size shred.pattern.umr.size || fail=1
89 done
91 Exit $fail