Hasard contains many tests to detect implementation bugs. To run all tests, type ”./run_tests.sh”. The most important test program is python/test_hasard.py.

You can also use the following programs to check random number generators quality: dieharder, ENT, TestU01.


  • Test entropy: python/file_info.py
  • Use ENT program: python/ent.py
  • Benchmark: benchmark.c
  • Manual visual check: python/gnuplot.py, python/draw_pil.py



test_hasard.py has many test suites applied on each generator. The script have command line options, the most useful are:

  • –slow / –very-slow: Slower tests, but test more cases
  • -r REPEAT: repeaet each test suite REPEAT times
  • -v: verbose

You can also test only one generator using its name, eg. “test_hasard.py arcfour”. Or you can run only some test suites using -k option, eg. “test_haasrd.py -k fork” runs all fork tests.


“init” test ensures that if two differents generators are created, the state is different. “reseed” is similar: it checks also for duplicate state, but after a “reseed” (call hasard_reseed() function). Both tests use the options –slow and –very-slow to choose how much tests are used:

  • Default: 10
  • –slow: 2^10
  • –very-slow: 2^20

dieharder and ENT

python/dieharder.py and python/ent.py require an Hasard data file. Use python/gen_files.py program to create such file. Examples:

./python/gen_files.py --rng=@fast --count=2**20 fast_ticks.dat
./python/gen_files.py --rng=@fast --op=ulong --min=0 --max=2**16-1 fast_ulong16.dat

Dieharder requires at least 2^24 numbers and is very slow (can take more than one hour).

ENT output is not really revelant, use Dieharder, or better TestU01.


TestU01 is a test suite written by Pierre l’Ecuyer: http://www.iro.umontreal.ca/~simardr/testu01/tu01.html

Example: ”./tools/testu01 @fast SmallCrush”.

Except SmallCrush and FIPS_140_2, most test suites are very slow (takes more than 10 hours).

Test RNG quality