]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
add command line option to specify list of tags of catch units to run
authordavis mcpherson <davis.mcpherson@gmail.com>
Thu, 27 Aug 2015 20:58:48 +0000 (16:58 -0400)
committerdavis mcpherson <davmcphe@cisco.com>
Thu, 27 Aug 2015 21:36:33 +0000 (17:36 -0400)
--catch-tags [footag],[bartag]

if unit-test mode is verbose enable logging of results from sucessful catch tests

src/main/snort_module.cc
src/test/unit_test.cc
src/test/unit_test.h

index f321c1327157700be5330f17ee6322735ee9e31a..7a95afbea7c8b74cb36a8c28b5fd45a1a3d17476 100644 (file)
@@ -444,6 +444,8 @@ static const Parameter s_params[] =
     { "--unit-test", Parameter::PT_SELECT,
       "silent | minimal | normal | verbose | env (export CK_VERBOSITY)", nullptr,
       "<verbosity> run unit tests with given libcheck output mode" },
+    { "--catch-tags", Parameter::PT_STRING, nullptr, nullptr,
+        "comma separated list of cat unit test tags" },
 #endif
     { "--version", Parameter::PT_IMPLIED, nullptr, nullptr,
       "show version number (same as -V)" },
@@ -834,6 +836,8 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
 #ifdef UNIT_TEST
     else if ( v.is("--unit-test") )
         unit_test_mode(v.get_string());
+    else if ( v.is("--catch-tags") )
+        unit_test_catch_test_filter(v.get_string());
 #endif
     else if ( v.is("--version") )
         help_version(sc, v.get_string());
index 2f2ec653fd547f83e2e954ed9e2d2c09b1427ac2..616b45ca65bf32cb274956e67675fa73fea02676 100644 (file)
@@ -17,6 +17,9 @@
 //--------------------------------------------------------------------------
 // unit_test.h author Russ Combs <rucombs@cisco.com>
 
+#include <vector>
+#include <string>
+
 #include "unit_test.h"
 
 #include <stdlib.h>
@@ -36,6 +39,7 @@
 #include "suite_decl.h"
 
 static print_output s_mode = CK_LAST;
+static std::vector<std::string> test_tags;
 
 typedef Suite* (* SuiteCtor_f)();
 
@@ -66,6 +70,11 @@ void unit_test_mode(const char* s)
         s_mode = CK_ENV;
 }
 
+void unit_test_catch_test_filter(const char* s)
+{
+    test_tags.push_back( s );
+}
+
 bool unit_test_enabled()
 {
     return s_mode != CK_LAST;
@@ -119,6 +128,11 @@ static bool run_catch()
 {
   Catch::Session session;
   // write to session.configData() or session.Config() to customize
+  if( s_mode == CK_VERBOSE )
+      session.configData().showSuccessfulTests = true;
+  if( test_tags.size() > 0 )
+      session.configData().testsOrTags = test_tags;
+
   return session.run() == 0;
 }
 
index e7b7b50bdcd2229a698b2f83911d842455a29588..9598f2af069b0ce0bce3ab39a3ae873a100978f3 100644 (file)
@@ -36,6 +36,7 @@
 void unit_test_mode(const char* = nullptr);
 bool unit_test_enabled();
 int unit_test();
+void unit_test_catch_test_filter(const char* s);
 
 #endif