mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Support for unit tests in plugins
This pushes the unit test kickoff down in the Zeek startup sequence, to give plugins a chance to register. It also enforces deterministic mode for unit testing, since without it some unit tests start to have nondeterministic results at that stage.
This commit is contained in:
parent
f8b8401d84
commit
f20f8ad4a8
2 changed files with 12 additions and 7 deletions
|
@ -629,6 +629,7 @@ install(FILES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/patricia.h
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/patricia.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/setsignal.h
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/setsignal.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/sqlite3.h
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/sqlite3.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/doctest.h
|
||||||
DESTINATION include/zeek/3rdparty
|
DESTINATION include/zeek/3rdparty
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -416,13 +416,7 @@ SetupResult setup(int argc, char** argv, Options* zopts)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( options.run_unit_tests )
|
if ( options.run_unit_tests )
|
||||||
{
|
options.deterministic_mode = true;
|
||||||
doctest::Context context;
|
|
||||||
auto dargs = to_cargs(options.doctest_args);
|
|
||||||
context.applyCommandLine(dargs.size(), dargs.data());
|
|
||||||
ZEEK_LSAN_ENABLE();
|
|
||||||
exit(context.run());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto stem = Supervisor::CreateStem(options.supervisor_mode);
|
auto stem = Supervisor::CreateStem(options.supervisor_mode);
|
||||||
|
|
||||||
|
@ -601,6 +595,16 @@ SetupResult setup(int argc, char** argv, Options* zopts)
|
||||||
|
|
||||||
plugin_mgr->ActivateDynamicPlugins(! options.bare_mode);
|
plugin_mgr->ActivateDynamicPlugins(! options.bare_mode);
|
||||||
|
|
||||||
|
// Delay the unit test until here so that plugins have been loaded.
|
||||||
|
if ( options.run_unit_tests )
|
||||||
|
{
|
||||||
|
doctest::Context context;
|
||||||
|
auto dargs = to_cargs(options.doctest_args);
|
||||||
|
context.applyCommandLine(dargs.size(), dargs.data());
|
||||||
|
ZEEK_LSAN_ENABLE();
|
||||||
|
exit(context.run());
|
||||||
|
}
|
||||||
|
|
||||||
// Print usage after plugins load so that any path extensions are properly shown.
|
// Print usage after plugins load so that any path extensions are properly shown.
|
||||||
if ( options.print_usage )
|
if ( options.print_usage )
|
||||||
usage(argv[0], 0);
|
usage(argv[0], 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue