From: davis mcpherson Date: Thu, 27 Aug 2015 20:58:48 +0000 (-0400) Subject: add command line option to specify list of tags of catch units to run X-Git-Tag: 3.0.0-233~860^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fcb481e76d6fa4b503d1ad99311e51d98164bb2;p=thirdparty%2Fsnort3.git add command line option to specify list of tags of catch units to run --catch-tags [footag],[bartag] if unit-test mode is verbose enable logging of results from sucessful catch tests --- diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index f321c1327..7a95afbea 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -444,6 +444,8 @@ static const Parameter s_params[] = { "--unit-test", Parameter::PT_SELECT, "silent | minimal | normal | verbose | env (export CK_VERBOSITY)", nullptr, " 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()); diff --git a/src/test/unit_test.cc b/src/test/unit_test.cc index 2f2ec653f..616b45ca6 100644 --- a/src/test/unit_test.cc +++ b/src/test/unit_test.cc @@ -17,6 +17,9 @@ //-------------------------------------------------------------------------- // unit_test.h author Russ Combs +#include +#include + #include "unit_test.h" #include @@ -36,6 +39,7 @@ #include "suite_decl.h" static print_output s_mode = CK_LAST; +static std::vector 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; } diff --git a/src/test/unit_test.h b/src/test/unit_test.h index e7b7b50bd..9598f2af0 100644 --- a/src/test/unit_test.h +++ b/src/test/unit_test.h @@ -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