From: Tom Peters Date: Tue, 7 Oct 2014 14:30:47 +0000 (-0400) Subject: don't open test input file when not going to use it X-Git-Tag: 3.0.0-233~1392 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f45f40cc462640cf2f352877836f07bff40dfd9;p=thirdparty%2Fsnort3.git don't open test input file when not going to use it --- diff --git a/src/service_inspectors/nhttp_inspect/nhttp_test_manager.cc b/src/service_inspectors/nhttp_inspect/nhttp_test_manager.cc index 61523e416..b889bab52 100644 --- a/src/service_inspectors/nhttp_inspect/nhttp_test_manager.cc +++ b/src/service_inspectors/nhttp_inspect/nhttp_test_manager.cc @@ -32,7 +32,7 @@ bool NHttpTestManager::test_input = false; bool NHttpTestManager::test_output = false; -NHttpTestInput NHttpTestManager::test_input_source("nhttp_test_msgs.txt"); +NHttpTestInput* NHttpTestManager::test_input_source = nullptr; const char* NHttpTestManager::test_output_prefix = "nhttpresults/testcase"; int64_t NHttpTestManager::test_number = -1; FILE* NHttpTestManager::test_out = nullptr; @@ -47,3 +47,10 @@ void NHttpTestManager::update_test_number(int64_t new_test_number) { } } +void NHttpTestManager::activate_test_input() { + test_input = true; + if (test_input_source == nullptr) { + test_input_source = new NHttpTestInput("nhttp_test_msgs.txt"); + } +} + diff --git a/src/service_inspectors/nhttp_inspect/nhttp_test_manager.h b/src/service_inspectors/nhttp_inspect/nhttp_test_manager.h index 67761b72e..fb851926c 100644 --- a/src/service_inspectors/nhttp_inspect/nhttp_test_manager.h +++ b/src/service_inspectors/nhttp_inspect/nhttp_test_manager.h @@ -42,9 +42,9 @@ class NHttpTestInput; class NHttpTestManager { public: static bool use_test_input() { return test_input; }; - static void activate_test_input() { test_input = true; }; + static void activate_test_input(); static void activate_test_output() { test_output = true; }; - static NHttpTestInput *get_test_input_source() { return &test_input_source; }; + static NHttpTestInput* get_test_input_source() { return test_input_source; }; static void update_test_number(int64_t new_test_number); static bool use_test_output() { return test_output || test_input; }; static FILE* get_output_file() { return (test_out != nullptr) ? test_out : stdout; }; @@ -54,7 +54,7 @@ private: // Test input read from file static bool test_input; - static NHttpTestInput test_input_source; + static NHttpTestInput* test_input_source; // Printing results of message processing static bool test_output;