diff --git a/src/ZeekString.cc b/src/ZeekString.cc index 860d444de1..2abc1c7cb9 100644 --- a/src/ZeekString.cc +++ b/src/ZeekString.cc @@ -535,9 +535,6 @@ TEST_CASE("construction") CHECK_EQ(s7.Len(), 6); CHECK_EQ(s7.Bytes(), text2); - // Construct a temporary reporter object for the next two tests - zeek::reporter = new zeek::Reporter(false); - zeek::byte_vec text3 = new u_char[7]; memcpy(text3, text.c_str(), 7); zeek::String s8{false, text3, 6}; @@ -549,8 +546,6 @@ TEST_CASE("construction") zeek::String s9{false, text4, 6}; CHECK_EQ(std::string(s9.CheckString()), ""); - delete zeek::reporter; - zeek::byte_vec text5 = (zeek::byte_vec)malloc(7); memcpy(text5, text.c_str(), 7); zeek::String s10{true, text5, 6}; diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index 98e87cfcbf..7b2878653f 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -679,7 +679,7 @@ SetupResult setup(int argc, char** argv, Options* zopts) if ( options.plugins_to_load.empty() && options.scripts_to_load.empty() && options.script_options_to_set.empty() && ! options.pcap_file && ! options.interface && ! options.identifier_to_print && ! command_line_policy && ! options.print_plugins && - ! options.supervisor_mode && ! Supervisor::ThisNode() ) + ! options.supervisor_mode && ! Supervisor::ThisNode() && ! options.run_unit_tests ) add_input_file("-"); for ( const auto& script_option : options.script_options_to_set ) @@ -726,17 +726,6 @@ SetupResult setup(int argc, char** argv, Options* zopts) plugin_mgr->ActivateDynamicPlugins(! options.bare_mode); - // Delay the unit test until here so that plugins have been loaded. - if ( options.run_unit_tests ) - { - set_signal_mask(false); // Allow ctrl-c to abort the tests early - 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. if ( options.print_usage ) usage(argv[0], 0); @@ -808,6 +797,18 @@ SetupResult setup(int argc, char** argv, Options* zopts) init_net_var(); run_bif_initializers(); + // Delay the unit test until here so that plugins and script + // types have been fully loaded. + if ( options.run_unit_tests ) + { + set_signal_mask(false); // Allow ctrl-c to abort the tests early + doctest::Context context; + auto dargs = to_cargs(options.doctest_args); + context.applyCommandLine(dargs.size(), dargs.data()); + ZEEK_LSAN_ENABLE(); + exit(context.run()); + } + // Assign the script_args for command line processing in Zeek scripts. if ( ! options.script_args.empty() ) {