[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 4/6] tests: discard: Remove dubious use of "/dev/urandom" as a Device parameter.



This API docs don't state that this is permitted.
---
 tests/discard/test-blkdiscard.pl | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tests/discard/test-blkdiscard.pl b/tests/discard/test-blkdiscard.pl
index 9f136ecd9..4505e678b 100755
--- a/tests/discard/test-blkdiscard.pl
+++ b/tests/discard/test-blkdiscard.pl
@@ -93,9 +93,21 @@ unless ($g->feature_available (["blkdiscard"])) {
 my $orig_size = (stat ($disk))[12];
 print "original size:\t$orig_size (blocks)\n";
 
-# Fill the block device with some random data.
-
-$g->copy_device_to_device ("/dev/urandom", "/dev/sda", size => $size);
+# Fill the block device with non-zero data.
+
+my $i = $size;
+my $offset = 0;
+while ($i > 0) {
+    my $data;
+    if ($i >= 1024*1024) {
+        $data = "*" x (1024*1024)
+    } else {
+        $data = "*" x $i
+    }
+    $g->pwrite_device ("/dev/sda", $data, $offset);
+    $offset += length $data;
+    $i -= length $data;
+}
 $g->sync ();
 
 my $full_size = (stat ($disk))[12];
-- 
2.13.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]