mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
btest/plugins: Add a plugin testing Init and Done hooks
Follow-up for #4047.
This commit is contained in:
parent
97f05b2f8c
commit
39b43e8dd6
5 changed files with 71 additions and 0 deletions
28
testing/btest/plugins/init-hooks-plugin/src/Plugin.cc
Normal file
28
testing/btest/plugins/init-hooks-plugin/src/Plugin.cc
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "Plugin.h"
|
||||
|
||||
#include <cstdio>
|
||||
namespace btest::plugin::Demo_InitHooks {
|
||||
Plugin plugin;
|
||||
}
|
||||
|
||||
using namespace btest::plugin::Demo_InitHooks;
|
||||
|
||||
zeek::plugin::Configuration Plugin::Configure() {
|
||||
setlinebuf(stdout);
|
||||
std::fprintf(stdout, "Configure()\n");
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Demo::InitHooks";
|
||||
config.description = "Test Init and Done hooks";
|
||||
config.version.major = 1;
|
||||
config.version.minor = 0;
|
||||
config.version.patch = 0;
|
||||
return config;
|
||||
}
|
||||
|
||||
void Plugin::InitPreScript() { std::fprintf(stdout, "InitPreScript()\n"); }
|
||||
|
||||
void Plugin::InitPostScript() { std::fprintf(stdout, "InitPostScript()\n"); }
|
||||
|
||||
void Plugin::InitPreExecution() { std::fprintf(stdout, "InitPreExecution()\n"); }
|
||||
|
||||
void Plugin::Done() { std::fprintf(stdout, "Done()\n"); }
|
18
testing/btest/plugins/init-hooks-plugin/src/Plugin.h
Normal file
18
testing/btest/plugins/init-hooks-plugin/src/Plugin.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
#include <zeek/plugin/Plugin.h>
|
||||
#include <cstdio>
|
||||
|
||||
namespace btest::plugin::Demo_InitHooks {
|
||||
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin {
|
||||
protected:
|
||||
zeek::plugin::Configuration Configure() override;
|
||||
void InitPreScript() override;
|
||||
void InitPostScript() override;
|
||||
void InitPreExecution() override;
|
||||
void Done() override;
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
} // namespace btest::plugin::Demo_InitHooks
|
Loading…
Add table
Add a link
Reference in a new issue