[PATCH 1 of 7] tests: don't use /dev/urandom for largefiles testing

Mads Kiilerich mads at kiilerich.com
Sun Apr 22 19:18:53 CDT 2012


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1335139008 -7200
# Branch stable
# Node ID 7b311bdc9614bb4f9e2715ca41d328978ad5618b
# Parent  4fe874697a4dc80f3a128569a1d6bd5d460ec9eb
tests: don't use /dev/urandom for largefiles testing

There is no need to use entropy here just to create some content that only will
be used for hashing and ignored.

This avoids a problem where dd from /dev/urandom on solaris generates too short
output.

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -74,6 +74,7 @@
     (r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"),
     (r'^alias\b.*=', "don't use alias, use a function"),
     (r'if\s*!', "don't use '!' to negate exit status"),
+    (r'/dev/u?random', "don't use entropy, use /dev/zero"),
   ],
   # warnings
   []
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -815,7 +815,7 @@
 
 Test --normal flag
 
-  $ dd if=/dev/urandom bs=2k count=11k > new-largefile 2> /dev/null
+  $ dd if=/dev/zero bs=2k count=11k > new-largefile 2> /dev/null
   $ hg add --normal --large new-largefile
   abort: --normal cannot be used with --large
   [255]
@@ -945,7 +945,7 @@
   $ cd alice
   $ hg init pubrepo
   $ cd pubrepo
-  $ dd if=/dev/urandom bs=1k count=11k > a-large-file 2> /dev/null
+  $ dd if=/dev/zero bs=1k count=11k > a-large-file 2> /dev/null
   $ hg add --large a-large-file
   $ hg commit -m "Add a large file"
   Invoking status precommit hook


More information about the Mercurial-devel mailing list