zeek/testing/btest/bifs/rand.bro
Jon Siwek 34ead91f99 Fix inconsistencies in random number generation.
The srand()/rand() interface was being intermixed with the
srandom()/random() one.  The later is now used throughout.

Changed the srand() and rand() BIFs to work deterministically if Bro
was given a seed file (addresses #825).  They also now wrap the
system's srandom() and random() instead of srand() and rand() as per
the above.
2012-06-29 16:24:31 -05:00

29 lines
423 B
Text

#
# @TEST-EXEC: bro -b %INPUT >out
# @TEST-EXEC: bro -b %INPUT do_seed=F >out.2
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff out.2
const do_seed = T &redef;
event bro_init()
{
local a = rand(1000);
local b = rand(1000);
local c = rand(1000);
print a;
print b;
print c;
if ( do_seed )
srand(575);
local d = rand(1000);
local e = rand(1000);
local f = rand(1000);
print d;
print e;
print f;
}