mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
scan.l: Fix @load-plugin scripts loading
For a plugin loaded via @load-plugin, create a YY_BUFFER_STATE holding the required loads for the implicitly loaded files. In loaded scripts, this generated file will show up with a path of the shared object file of the plugin with the __preload__.zeek and __load__.zeek files loaded by it. Closes #2311
This commit is contained in:
parent
d079a2b9a8
commit
ab99f8e233
8 changed files with 157 additions and 8 deletions
|
@ -0,0 +1,11 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
<...>/enum-bif-plugin.zeek
|
||||
<...>/enum-before-load-plugin.zeek
|
||||
<...>/Demo-EnumBif.shared
|
||||
<...>/__preload__.zeek
|
||||
<...>/types.zeek
|
||||
<...>/__load__.zeek
|
||||
<...>/enumbif.bif.zeek
|
||||
<...>/__load__.zeek
|
||||
<...>/enum-after-load-plugin.zeek
|
||||
<...>/enum-after-load-plugin-end.zeek
|
|
@ -0,0 +1,11 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
<...>/enum-bif-plugin.zeek
|
||||
<...>/enum-before-load-plugin.zeek
|
||||
.<...>/Demo-EnumBif.shared
|
||||
<...>/__preload__.zeek
|
||||
<...>/types.zeek
|
||||
<...>/__load__.zeek
|
||||
<...>/enumbif.bif.zeek
|
||||
<...>/__load__.zeek
|
||||
<...>/enum-after-load-plugin.zeek
|
||||
<...>/enum-after-load-plugin-end.zeek
|
|
@ -0,0 +1,6 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
EnumBif::MyEnumA
|
||||
{
|
||||
EnumBif::MyEnumB,
|
||||
EnumBif::MyEnumA
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
EnumBif::MyEnumA
|
||||
{
|
||||
EnumBif::MyEnumB,
|
||||
EnumBif::MyEnumA
|
||||
}
|
45
testing/btest/plugins/enum-bif-plugin.zeek
Normal file
45
testing/btest/plugins/enum-bif-plugin.zeek
Normal 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
|
0
testing/btest/plugins/enum-bif-plugin/.btest-ignore
Normal file
0
testing/btest/plugins/enum-bif-plugin/.btest-ignore
Normal file
6
testing/btest/plugins/enum-bif-plugin/src/enumbif.bif
Normal file
6
testing/btest/plugins/enum-bif-plugin/src/enumbif.bif
Normal file
|
@ -0,0 +1,6 @@
|
|||
module EnumBif;
|
||||
|
||||
enum MyEnum %{
|
||||
MyEnumA,
|
||||
MyEnumB,
|
||||
%}
|
Loading…
Add table
Add a link
Reference in a new issue