dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] test: increase test data sizes to fill socket buffers
@ 2016-12-16 10:29 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-12-16 10:29 UTC (permalink / raw)
  To: spew

Some Debian build machines use insanely large socket
buffers, so increase our test buffers to large values to
force EAGAIN: https://bugs.debian.org/830353

In my experience, using setsockopt to clamp buffers to small sizes
can lead to unpredictable stalls, too, so it might not be good
to do in a test case, either.
---
 test/lib_read_write.rb | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/test/lib_read_write.rb b/test/lib_read_write.rb
index 26e7aef..5f70964 100644
--- a/test/lib_read_write.rb
+++ b/test/lib_read_write.rb
@@ -7,7 +7,12 @@ $-w = true
 require 'kgio'
 
 module LibReadWriteTest
-  RANDOM_BLOB = File.open("/dev/urandom") { |fp| fp.read(10 * 1024 * 1024) }
+  RANDOM_BLOB = File.open("/dev/urandom") do |fp|
+    nr = 31
+    buf = fp.read(nr)
+    # get roughly a 20MB block of random data
+    (buf * (20 * 1024 * 1024 / nr)) + (buf * rand(123))
+  end
 
   def teardown
     @rd.close if defined?(@rd) && ! @rd.closed?
@@ -369,7 +374,7 @@ module LibReadWriteTest
       @nr += 1
       IO.select(nil, [self])
     end
-    buf = "." * 1024 * 1024 * 10
+    buf = RANDOM_BLOB
     thr = Thread.new { @wr.kgio_write(buf) }
     Thread.pass until thr.stop?
     readed = @rd.read(buf.size)
@@ -385,7 +390,7 @@ module LibReadWriteTest
       @nr += 1
       IO.select(nil, [self])
     end
-    buf = ["." * 1024] * 1024 * 10
+    buf = [ RANDOM_BLOB, RANDOM_BLOB ]
     buf_size = buf.inject(0){|c, s| c + s.size}
     thr = Thread.new { @wr.kgio_writev(buf) }
     Thread.pass until thr.stop?
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-12-16 10:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 10:29 [PATCH] test: increase test data sizes to fill socket buffers Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).