mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00

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.
29 lines
423 B
Text
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;
|
|
}
|