From 39e1f71ebfd38bdfa548432a43c99bca50ef7a0b Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Thu, 16 Nov 2023 13:03:40 -0800 Subject: [PATCH] BTests for testing that event handler coalescence operates as expected --- testing/btest/Baseline/opt.coalescence/output | 5 ++++ .../btest/Baseline/opt.no-coalescence/output | 5 ++++ testing/btest/opt/coalescence.zeek | 23 +++++++++++++++++++ testing/btest/opt/no-coalescence.zeek | 23 +++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 testing/btest/Baseline/opt.coalescence/output create mode 100644 testing/btest/Baseline/opt.no-coalescence/output create mode 100644 testing/btest/opt/coalescence.zeek create mode 100644 testing/btest/opt/no-coalescence.zeek diff --git a/testing/btest/Baseline/opt.coalescence/output b/testing/btest/Baseline/opt.coalescence/output new file mode 100644 index 0000000000..90b992b6cc --- /dev/null +++ b/testing/btest/Baseline/opt.coalescence/output @@ -0,0 +1,5 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +my_event +ZAM-code my_event +second instance, higher priority +first instance, lower priority diff --git a/testing/btest/Baseline/opt.no-coalescence/output b/testing/btest/Baseline/opt.no-coalescence/output new file mode 100644 index 0000000000..9fa75ea74d --- /dev/null +++ b/testing/btest/Baseline/opt.no-coalescence/output @@ -0,0 +1,5 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +my_event +ZAM-code my_event ZAM-code my_event +second instance, higher priority +first instance, lower priority diff --git a/testing/btest/opt/coalescence.zeek b/testing/btest/opt/coalescence.zeek new file mode 100644 index 0000000000..9552c168ba --- /dev/null +++ b/testing/btest/opt/coalescence.zeek @@ -0,0 +1,23 @@ +# @TEST-DOC: Ensure that event coalescence works properly. +# +# @TEST-EXEC: zeek -b -O ZAM %INPUT >output +# @TEST-EXEC: btest-diff output + +event my_event() &priority=-10 + { + print "first instance, lower priority"; + } + +event my_event() &priority=10 + { + print "second instance, higher priority"; + } + +event zeek_init() + { + # This should print a single event handler body. + print my_event; + + # Make sure execution of both handlers happens properly. + event my_event(); + } diff --git a/testing/btest/opt/no-coalescence.zeek b/testing/btest/opt/no-coalescence.zeek new file mode 100644 index 0000000000..2bd87bd413 --- /dev/null +++ b/testing/btest/opt/no-coalescence.zeek @@ -0,0 +1,23 @@ +# @TEST-DOC: Ensure that event coalescence doesn't happen if inlining turned off. +# +# @TEST-EXEC: zeek -b -O ZAM -O no-inline %INPUT >output +# @TEST-EXEC: btest-diff output + +event my_event() &priority=-10 + { + print "first instance, lower priority"; + } + +event my_event() &priority=10 + { + print "second instance, higher priority"; + } + +event zeek_init() + { + # This should print two event handler bodies. + print my_event; + + # Make sure execution of both handlers happens properly. + event my_event(); + }