mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 12:08:20 +00:00
Merge remote-tracking branch 'origin/topic/robin/gh-1179-plugin-loading'
* origin/topic/robin/gh-1179-plugin-loading: Retry loading plugins on failure to resolve to dependencies. Fix use of deprecated functionality in test. When attempting to activate a plugin, load dynamic libraries first. Add test creating multiple plugins with load dependencies.
This commit is contained in:
commit
eccbbb4476
15 changed files with 308 additions and 108 deletions
18
testing/btest/Baseline/plugins.plugin-load-dependency/output
Normal file
18
testing/btest/Baseline/plugins.plugin-load-dependency/output
Normal file
|
@ -0,0 +1,18 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
Testing::Plugin2 - Plugin2 provides a load dependency for Plugin1 and Plugin3 (dynamic, version 1.0.0)
|
||||
Testing::Plugin3 - Plugin3 has a load dependency on Plugin2 (dynamic, version 1.0.0)
|
||||
in Plugin2
|
||||
in Plugin3
|
||||
|
||||
Testing::Plugin1 - Plugin1 has a load dependency on Plugin2 (dynamic, version 1.0.0)
|
||||
Testing::Plugin2 - Plugin2 provides a load dependency for Plugin1 and Plugin3 (dynamic, version 1.0.0)
|
||||
in Plugin1
|
||||
in Plugin2
|
||||
|
||||
Testing::Plugin1 - Plugin1 has a load dependency on Plugin2 (dynamic, version 1.0.0)
|
||||
Testing::Plugin2 - Plugin2 provides a load dependency for Plugin1 and Plugin3 (dynamic, version 1.0.0)
|
||||
Testing::Plugin3 - Plugin3 has a load dependency on Plugin2 (dynamic, version 1.0.0)
|
||||
in Plugin1
|
||||
in Plugin2
|
||||
in Plugin2
|
||||
in Plugin3
|
|
@ -51,7 +51,7 @@ EOF
|
|||
cat >src/foo.bif <<EOF
|
||||
function hello_plugin_world%(%): string
|
||||
%{
|
||||
return new StringVal("Hello from the plugin!");
|
||||
return make_intrusive<StringVal>("Hello from the plugin!");
|
||||
%}
|
||||
|
||||
event plugin_event%(foo: count%);
|
||||
|
|
31
testing/btest/plugins/plugin-load-dependency.zeek
Normal file
31
testing/btest/plugins/plugin-load-dependency.zeek
Normal file
|
@ -0,0 +1,31 @@
|
|||
# @TEST-EXEC: mkdir 1
|
||||
# @TEST-EXEC: cd 1 && ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Testing Plugin1
|
||||
# @TEST-EXEC: cp -r %DIR/plugin-load-dependency/1 .
|
||||
# @TEST-EXEC: cd 1 && ./configure --zeek-dist=${DIST} && make
|
||||
|
||||
# @TEST-EXEC: mkdir 2
|
||||
# @TEST-EXEC: cd 2 && ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Testing Plugin2
|
||||
# @TEST-EXEC: cp -r %DIR/plugin-load-dependency/2 .
|
||||
# @TEST-EXEC: cd 2 && ./configure --zeek-dist=${DIST} && make
|
||||
|
||||
# @TEST-EXEC: mkdir 3
|
||||
# @TEST-EXEC: cd 3 && ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Testing Plugin3
|
||||
# @TEST-EXEC: cp -r %DIR/plugin-load-dependency/3 .
|
||||
# @TEST-EXEC: cd 3 && ./configure --zeek-dist=${DIST} && make
|
||||
|
||||
# The following run will only work if Zeek loads plugin2 before plugin3 (which
|
||||
# by alphabetical loading will be the case)
|
||||
# @TEST-EXEC: ZEEK_PLUGIN_PATH=. zeek -b -N Testing::Plugin3 Testing::Plugin2 | grep -v Zeek:: | sort >> output
|
||||
#
|
||||
# @TEST-EXEC: echo >>output
|
||||
#
|
||||
# The following run will only work if Zeek loads plugin2 before plugin1 (which
|
||||
# by alphabetical loading will not be the case).
|
||||
# @TEST-EXEC: ZEEK_PLUGIN_PATH=. zeek -b -N Testing::Plugin1 Testing::Plugin2 | grep -v Zeek:: | sort >> output
|
||||
#
|
||||
# @TEST-EXEC: echo >>output
|
||||
#
|
||||
# Finally, try it with self-discovery of all three plugins too.
|
||||
# @TEST-EXEC: ZEEK_PLUGIN_PATH=. zeek -N | grep -v Zeek:: | sort >> output
|
||||
#
|
||||
# @TEST-EXEC: btest-diff output
|
23
testing/btest/plugins/plugin-load-dependency/1/src/Plugin.cc
Normal file
23
testing/btest/plugins/plugin-load-dependency/1/src/Plugin.cc
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
#include "Plugin.h"
|
||||
|
||||
namespace btest::plugin::Testing_Plugin1 { Plugin plugin; }
|
||||
|
||||
using namespace btest::plugin::Testing_Plugin1;
|
||||
|
||||
extern void Plugin2_foo();
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Testing::Plugin1";
|
||||
config.description = "Plugin1 has a load dependency on Plugin2";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
|
||||
printf("in Plugin1\n");
|
||||
Plugin2_foo();
|
||||
|
||||
return config;
|
||||
}
|
17
testing/btest/plugins/plugin-load-dependency/1/src/Plugin.h
Normal file
17
testing/btest/plugins/plugin-load-dependency/1/src/Plugin.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Testing_Plugin1 {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
21
testing/btest/plugins/plugin-load-dependency/2/src/Plugin.cc
Normal file
21
testing/btest/plugins/plugin-load-dependency/2/src/Plugin.cc
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
#include "Plugin.h"
|
||||
|
||||
namespace btest::plugin::Testing_Plugin2 { Plugin plugin; }
|
||||
|
||||
using namespace btest::plugin::Testing_Plugin2;
|
||||
|
||||
void Plugin2_foo() {
|
||||
printf("in Plugin2\n");
|
||||
}
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Testing::Plugin2";
|
||||
config.description = "Plugin2 provides a load dependency for Plugin1 and Plugin3";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
return config;
|
||||
}
|
17
testing/btest/plugins/plugin-load-dependency/2/src/Plugin.h
Normal file
17
testing/btest/plugins/plugin-load-dependency/2/src/Plugin.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Testing_Plugin2 {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
23
testing/btest/plugins/plugin-load-dependency/3/src/Plugin.cc
Normal file
23
testing/btest/plugins/plugin-load-dependency/3/src/Plugin.cc
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
#include "Plugin.h"
|
||||
|
||||
namespace btest::plugin::Testing_Plugin3 { Plugin plugin; }
|
||||
|
||||
using namespace btest::plugin::Testing_Plugin3;
|
||||
|
||||
extern void Plugin2_foo();
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure()
|
||||
{
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Testing::Plugin3";
|
||||
config.description = "Plugin3 has a load dependency on Plugin2";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
|
||||
printf("in Plugin3\n");
|
||||
Plugin2_foo();
|
||||
|
||||
return config;
|
||||
}
|
17
testing/btest/plugins/plugin-load-dependency/3/src/Plugin.h
Normal file
17
testing/btest/plugins/plugin-load-dependency/3/src/Plugin.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
|
||||
namespace btest::plugin::Testing_Plugin3 {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
protected:
|
||||
// Overridden from zeek::plugin::Plugin.
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue