blob: 61ca60befd2709725a72deefbf7458722714ae45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/sh
# Verify the operations done by shred
# Copyright (C) 2009-2022 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ shred
# shred a single letter, which should result in
# 3 random passes and a single rename.
printf 1 > f || framework_failure_
echo "\
shred: f: pass 1/3 (random)...
shred: f: pass 2/3 (random)...
shred: f: pass 3/3 (random)...
shred: f: removing
shred: f: renamed to 0
shred: f: removed" > exp || framework_failure_
shred -v -u f 2>out || fail=1
compare exp out || fail=1
# Likewise but for a zero length file
# to bypass the data passes
touch f || framework_failure_
echo "\
shred: f: removing
shred: f: renamed to 0
shred: f: removed" > exp || framework_failure_
shred -v -u f 2>out || fail=1
compare exp out || fail=1
# shred data 20 times and verify the passes used.
# This would consume all random data between 5.93 and 8.24 inclusive.
dd bs=100K count=1 if=/dev/zero | tr '\0' 'U' > Us || framework_failure_
printf 1 > f || framework_failure_
echo "\
shred: f: pass 1/20 (random)...
shred: f: pass 2/20 (ffffff)...
shred: f: pass 3/20 (924924)...
shred: f: pass 4/20 (888888)...
shred: f: pass 5/20 (db6db6)...
shred: f: pass 6/20 (777777)...
shred: f: pass 7/20 (492492)...
shred: f: pass 8/20 (bbbbbb)...
shred: f: pass 9/20 (555555)...
shred: f: pass 10/20 (aaaaaa)...
shred: f: pass 11/20 (random)...
shred: f: pass 12/20 (6db6db)...
shred: f: pass 13/20 (249249)...
shred: f: pass 14/20 (999999)...
shred: f: pass 15/20 (111111)...
shred: f: pass 16/20 (000000)...
shred: f: pass 17/20 (b6db6d)...
shred: f: pass 18/20 (eeeeee)...
shred: f: pass 19/20 (333333)...
shred: f: pass 20/20 (random)...
shred: f: removing
shred: f: renamed to 0
shred: f: removed" > exp || framework_failure_
shred -v -u -n20 -s4096 --random-source=Us f 2>out || fail=1
compare exp out || fail=1
# Trigger an issue in shred before v8.27 where single
# bytes in the pattern space were not initialized correctly
# for particular sizes, like 7,13,...
# This failed under both valgrind and ASAN.
for size in 1 2 6 7 8; do
touch shred.pattern.umr.size
shred -n4 -s$size shred.pattern.umr.size || fail=1
done
Exit $fail
|