From a3b1d202a59c4e615d0274c01d9271f85cdcc95b Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Fri, 7 Feb 2020 15:06:56 -0800 Subject: [PATCH] Improve stability of a &expire_func btest The order in which &expire_func's get called isn't well-defined, so separate the output from either to ensure diffs against the Baseline are always consistent. --- CHANGES | 4 ++++ VERSION | 2 +- testing/btest/Baseline/language.expire_func_mod/out | 9 --------- testing/btest/Baseline/language.expire_func_mod/out2 | 9 +++++++++ testing/btest/language/expire_func_mod.zeek | 11 +++++++---- 5 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 testing/btest/Baseline/language.expire_func_mod/out2 diff --git a/CHANGES b/CHANGES index cade9e82e9..110fd3a10d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +3.1.0-dev.598 | 2020-02-07 15:06:56 -0800 + + * Improve stability of a &expire_func btest (Jon Siwek, Corelight) + 3.1.0-dev.597 | 2020-02-07 15:25:56 -0700 * plugin/Manager: migrate to std::string_view (Max Kellermann) diff --git a/VERSION b/VERSION index 0cd8c3910e..dd6629aa6b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.0-dev.597 +3.1.0-dev.598 diff --git a/testing/btest/Baseline/language.expire_func_mod/out b/testing/btest/Baseline/language.expire_func_mod/out index a11dad96aa..5d76ec8018 100644 --- a/testing/btest/Baseline/language.expire_func_mod/out +++ b/testing/btest/Baseline/language.expire_func_mod/out @@ -1,20 +1,11 @@ starting: ashish, 1 starting: ashish, 1 inside table_expire_func: ashish, 2 -inside table_expire_func: [ashish, ashish], 2 inside table_expire_func: ashish, 3 -inside table_expire_func: [ashish, ashish], 3 inside table_expire_func: ashish, 4 -inside table_expire_func: [ashish, ashish], 4 inside table_expire_func: ashish, 5 -inside table_expire_func: [ashish, ashish], 5 inside table_expire_func: ashish, 6 -inside table_expire_func: [ashish, ashish], 6 inside table_expire_func: ashish, 7 -inside table_expire_func: [ashish, ashish], 7 inside table_expire_func: ashish, 8 -inside table_expire_func: [ashish, ashish], 8 inside table_expire_func: ashish, 9 -inside table_expire_func: [ashish, ashish], 9 inside table_expire_func: ashish, 10 -inside table_expire_func: [ashish, ashish], 10 diff --git a/testing/btest/Baseline/language.expire_func_mod/out2 b/testing/btest/Baseline/language.expire_func_mod/out2 new file mode 100644 index 0000000000..e81af8ed98 --- /dev/null +++ b/testing/btest/Baseline/language.expire_func_mod/out2 @@ -0,0 +1,9 @@ +inside table_expire_func: [ashish, ashish], 2 +inside table_expire_func: [ashish, ashish], 3 +inside table_expire_func: [ashish, ashish], 4 +inside table_expire_func: [ashish, ashish], 5 +inside table_expire_func: [ashish, ashish], 6 +inside table_expire_func: [ashish, ashish], 7 +inside table_expire_func: [ashish, ashish], 8 +inside table_expire_func: [ashish, ashish], 9 +inside table_expire_func: [ashish, ashish], 10 diff --git a/testing/btest/language/expire_func_mod.zeek b/testing/btest/language/expire_func_mod.zeek index bdb6d19cca..a41031abbf 100644 --- a/testing/btest/language/expire_func_mod.zeek +++ b/testing/btest/language/expire_func_mod.zeek @@ -1,11 +1,14 @@ # @TEST-EXEC: zeek -b %INPUT >out # @TEST-EXEC: btest-diff out +# @TEST-EXEC: btest-diff out2 module Test; redef exit_only_after_terminate = T; redef table_expire_interval = .1 secs ; +global out2 = open("out2"); + export { global table_expire_func: function(t: table[string] of count, s: string): interval; @@ -49,10 +52,10 @@ function table_expire_func(t: table[string] of count, s: string): interval function table_expire_func2 (tt: table[string, string, string] of count, s: string, s2: string, s3: string): interval { tt[s, s2, s3] += 1; - - print fmt("inside table_expire_func: [%s, %s], %s", s, s2, tt[s, s2, s3]); - if ( tt[s, s2, s3] < 10 ) + print out2, fmt("inside table_expire_func: [%s, %s], %s", s, s2, tt[s, s2, s3]); + + if ( tt[s, s2, s3] < 10 ) return .1 secs ; schedule .1sec { die() }; @@ -66,4 +69,4 @@ event zeek_init() tt[s, s, s] = 1; print fmt("starting: %s, %s", s, t[s]); print fmt("starting: %s, %s", s, tt[s, s, s]); - } \ No newline at end of file + }