summaryrefslogtreecommitdiffstats
path: root/tools/test/devrandom/stat.8bit
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>1995-11-04 09:50:48 +0000
committermarkm <markm@FreeBSD.org>1995-11-04 09:50:48 +0000
commit420728c56820009ab1d7dcd05c6fa12ed03aeda8 (patch)
tree640094f2b9bcef301fc5179c062150e1f6b34b32 /tools/test/devrandom/stat.8bit
parent086c0271eed83e318fd98b71b2000b4082a86f73 (diff)
downloadFreeBSD-src-420728c56820009ab1d7dcd05c6fa12ed03aeda8.zip
FreeBSD-src-420728c56820009ab1d7dcd05c6fa12ed03aeda8.tar.gz
Add the test programs that I tested the /dev/random driver with.
Diffstat (limited to 'tools/test/devrandom/stat.8bit')
-rw-r--r--tools/test/devrandom/stat.8bit29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/test/devrandom/stat.8bit b/tools/test/devrandom/stat.8bit
new file mode 100644
index 0000000..5c304cb
--- /dev/null
+++ b/tools/test/devrandom/stat.8bit
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+#
+# Perform primitive binning into 8-bit bins (take 8 bits of randomness
+# at a time) and see if the distribution is flat. The output should be
+# checked by eye - are all the numbers roughly the same?
+#
+# Redirect the output from this to a file - and make a cup of coffee while
+# it runs. This program is a CPU Hog!
+#
+# $Id$
+#
+
+for ($i = 0; $i < (1024*32); $i++) {
+ open(BIN, "/dev/urandom") || die "Cannot open /dev/urandom - $!\n";
+ $len = sysread(BIN, $a, 256);
+ close(BIN);
+ if ($len > 0) {
+ for ($j = 0; $j < $len; $j++) {
+ $k = unpack("C", substr($a, $j, 1));
+ $bin[$k]++;
+ }
+ }
+}
+
+for ($i = 0; $i < 256; $i++) {
+ printf("%.2X ", $bin[$i]);
+}
+printf "\n";
OpenPOWER on IntegriCloud