Merge remote-tracking branch 'origin/topic/awelzel/2311-load-plugin-bare-mode'

* origin/topic/awelzel/2311-load-plugin-bare-mode:
  scan.l: Fix @load-plugin scripts loading
  scan.l: Extract switch_to() from load_files()
  ScannedFile: Allow skipping canonicalization

(cherry picked from commit a3a08fa0f3)
This commit is contained in:
Arne Welzel 2025-03-04 09:40:41 +01:00 committed by Tim Wojtulewicz
parent de8127f3cd
commit ec04c925a0
12 changed files with 209 additions and 25 deletions

View file

@ -0,0 +1,45 @@
# @TEST-DOC: Ensure the enum from the .bif file is available right after @load-plugin in bare mode.
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo EnumBif
# @TEST-EXEC: cp -r %DIR/enum-bif-plugin/* .
#
# @TEST-EXEC: ./configure --zeek-dist=${DIST} && make
#
# @TEST-EXEC: ZEEK_PLUGIN_PATH=`pwd` zeek -b %INPUT >output.abs
# @TEST-EXEC: grep '[Ee]num' loaded_scripts.log > loaded_scripts.log.abs
# @TEST-EXEC: ZEEK_PLUGIN_PATH=./build zeek -b %INPUT >output.rel
# @TEST-EXEC: grep '[Ee]num' loaded_scripts.log > loaded_scripts.log.rel
#
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output.abs
# @TEST-EXEC: TEST_DIFF_CANONIFIER="sed -E 's/(Demo-EnumBif)\.(.*)$/\1.shared/' | $SCRIPTS/diff-remove-abspath" btest-diff loaded_scripts.log.abs
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output.rel
# @TEST-EXEC: TEST_DIFF_CANONIFIER="sed -E 's/(Demo-EnumBif)\.(.*)$/\1.shared/' | $SCRIPTS/diff-remove-abspath" btest-diff loaded_scripts.log.rel
@load misc/loaded-scripts
@load ./enum-before-load-plugin
@load-plugin Demo::EnumBif
@load ./enum-after-load-plugin
event zeek_init()
{
print(EnumBif::MyEnumA);
print enum_names(EnumBif::MyEnum);
}
@load-plugin Demo::EnumBif
@load ./enum-after-load-plugin-end
@TEST-START-FILE enum-before-load-plugin.zeek
# empty
@TEST-END-FILE
@TEST-START-FILE enum-after-load-plugin.zeek
# empty
@TEST-END-FILE
@TEST-START-FILE enum-after-load-plugin-end.zeek
# empty
@TEST-END-FILE