4 # Test program for /dev/urandom
5 # Read and display random numbers.
6 # This also reads /dev/zero to make sure there is no brokenness there.
11 open(ZERO, "/dev/zero") || die "Cannot open /dev/zero - $!\n";
14 open(BIN, "/dev/urandom");
15 $len = sysread(BIN, $a, 20);
16 sysread(ZERO, $b, 20);
19 for ($j = 0; $j < $len; $j += 2) {
20 $k = unpack("S", substr($a, $j, 2));
21 $z = unpack("S", substr($b, $j, 2));
22 $z == 0 || die "/dev/zero is returning non-zero!\n";