mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 23:43:26 +01:00
tests: Replace calls to dd with native writeZeroes
This commit is contained in:
parent
8620b46d56
commit
7732466277
@ -72,5 +72,26 @@ sub waitForFile
|
||||
return 0;
|
||||
}
|
||||
|
||||
# writeZeroes($filename, $size)
|
||||
# Write zeroes of size $size to file $filename
|
||||
sub writeZeroes
|
||||
{
|
||||
my $filename = shift;
|
||||
my $size = shift;
|
||||
open(my $fh, ">", $filename);
|
||||
my $bs = 4096; # 4 KiB
|
||||
my $block = "\0" x $bs;
|
||||
my $remain;
|
||||
for($remain = $size; $remain >= $bs; $remain -= $bs)
|
||||
{
|
||||
print($fh $block) or BAIL_OUT("Could not write to $filename: $!");
|
||||
}
|
||||
if($remain > 0)
|
||||
{
|
||||
$block = "\0" x $remain;
|
||||
print($fh $block) or BAIL_OUT("Could not write to $filename: $!");
|
||||
}
|
||||
}
|
||||
|
||||
# As this file will be require()'d, it needs to return true
|
||||
return 1;
|
||||
|
@ -88,7 +88,7 @@ sub corruption
|
||||
sub internalModification
|
||||
{
|
||||
$ofile = "$workingDir/crypt-internal-$$";
|
||||
qx(dd if=/dev/urandom of=$ofile bs=2k count=2 2> /dev/null);
|
||||
writeZeroes($ofile, 2*1024);
|
||||
ok(copy($ofile, "$crypt/internal"), "copying crypt-internal file");
|
||||
|
||||
open(my $out1, "+<", "$crypt/internal");
|
||||
|
@ -129,7 +129,7 @@ sub grow {
|
||||
}
|
||||
|
||||
sub largeRead {
|
||||
system("dd if=/dev/zero of=$plain/largeRead bs=1M count=1 2> /dev/null");
|
||||
writeZeroes("$plain/largeRead", 1024*1024);
|
||||
# ciphertext file name
|
||||
my $cname = encName("largeRead");
|
||||
# cfh ... ciphertext file handle
|
||||
|
Loading…
Reference in New Issue
Block a user