mirror of
https://github.com/vgough/encfs.git
synced 2025-06-20 03:37:50 +02: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;
|
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
|
# As this file will be require()'d, it needs to return true
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -88,7 +88,7 @@ sub corruption
|
|||||||
sub internalModification
|
sub internalModification
|
||||||
{
|
{
|
||||||
$ofile = "$workingDir/crypt-internal-$$";
|
$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");
|
ok(copy($ofile, "$crypt/internal"), "copying crypt-internal file");
|
||||||
|
|
||||||
open(my $out1, "+<", "$crypt/internal");
|
open(my $out1, "+<", "$crypt/internal");
|
||||||
|
@ -129,7 +129,7 @@ sub grow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub largeRead {
|
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
|
# ciphertext file name
|
||||||
my $cname = encName("largeRead");
|
my $cname = encName("largeRead");
|
||||||
# cfh ... ciphertext file handle
|
# cfh ... ciphertext file handle
|
||||||
|
Loading…
x
Reference in New Issue
Block a user