From 26d9517774b2c65ec4f561c527f0501922d37b48 Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Thu, 6 Oct 2016 12:56:52 -0700 Subject: [PATCH] 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. --- testing/btest/Baseline/plugins.reader/out | 10 +++++----- testing/btest/plugins/reader-plugin/src/Foo.cc | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/testing/btest/Baseline/plugins.reader/out b/testing/btest/Baseline/plugins.reader/out index 9dd3101a8d..8d8c46dd8e 100644 --- a/testing/btest/Baseline/plugins.reader/out +++ b/testing/btest/Baseline/plugins.reader/out @@ -1,10 +1,10 @@ Input::EVENT_NEW -^)kHV32-J_ +1K@_(-PQ7S Input::EVENT_NEW -(s[Q8J4Pu4 +PS17T[f6s\ Input::EVENT_NEW -+3iDbOB}kq +39P|JR@F_C Input::EVENT_NEW -tz9dFehHz) +#iHW2{G_22 Input::EVENT_NEW -d&@3g)NljG +#Ykb&UeAwg diff --git a/testing/btest/plugins/reader-plugin/src/Foo.cc b/testing/btest/plugins/reader-plugin/src/Foo.cc index 9d79361068..acfd094aa9 100644 --- a/testing/btest/plugins/reader-plugin/src/Foo.cc +++ b/testing/btest/plugins/reader-plugin/src/Foo.cc @@ -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; }