]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
don't open test input file when not going to use it
authorTom Peters <thopeter@cisco.com>
Tue, 7 Oct 2014 14:30:47 +0000 (10:30 -0400)
committerTom Peters <thopeter@cisco.com>
Tue, 7 Oct 2014 14:30:47 +0000 (10:30 -0400)
src/service_inspectors/nhttp_inspect/nhttp_test_manager.cc
src/service_inspectors/nhttp_inspect/nhttp_test_manager.h

index 61523e4160c347b84ff8de7e2ef4a6e44545721a..b889bab52db1bd906da34f14982c713993e164d8 100644 (file)
@@ -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");
+    }
+}
+
index 67761b72ea3e27645f0348278ee7277a1f980847..fb851926c7f0e6d64934cab113fc05f83d03d33b 100644 (file)
@@ -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;