Use the deterministic bro_random in a test, instead of os random().

The previous test stopped working on FreeBSD 11.0, and I am actually not
quite sure why this ever worked as stable as it did.
This commit is contained in:
Johanna Amann 2016-10-06 12:56:52 -07:00
parent 544317fc1e
commit 26d9517774
2 changed files with 9 additions and 6 deletions

View file

@ -45,7 +45,10 @@ string Foo::RandomString(const int len)
"abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < len; ++i)
s[i] = values[random() / (RAND_MAX / sizeof(values))];
// bro_random is not thread-safe; as we are only using one simultaneous thread
// here, this should not matter in this case. If this test ever starts showing
// random errors, this might be the culprit.
s[i] = values[bro_random() / (RAND_MAX / sizeof(values))];
return s;
}