From: russ Date: Tue, 8 Sep 2015 22:46:43 +0000 (-0400) Subject: remove check related build foo and code X-Git-Tag: 3.0.0-233~844^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=569dd23cb9e7e60c4bee7df36080669775d6afdd;p=thirdparty%2Fsnort3.git remove check related build foo and code --- diff --git a/src/main.cc b/src/main.cc index 3fc10665f..e2b61a821 100644 --- a/src/main.cc +++ b/src/main.cc @@ -696,9 +696,6 @@ static bool set_mode() exit(Piglet::main()); #endif #ifdef UNIT_TEST - if ( check_enabled() ) - exit(check_test()); - if ( catch_enabled() ) exit(catch_test()); #endif diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index 648379059..90f9680c3 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -441,10 +441,6 @@ static const Parameter s_params[] = "use drop, sdrop, and reject rules to ignore session traffic when not inline" }, #ifdef UNIT_TEST - { "--check-test", Parameter::PT_SELECT, - "silent | minimal | normal | verbose | env (export CK_VERBOSITY)", nullptr, - " run unit tests with given libcheck output mode" }, - { "--catch-test", Parameter::PT_STRING, nullptr, nullptr, "comma separated list of cat unit test tags or 'all'" }, #endif @@ -835,9 +831,6 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc) ConfigTreatDropAsIgnore(sc, v.get_string()); #ifdef UNIT_TEST - else if ( v.is("--check-test") ) - unit_test_mode(v.get_string()); - else if ( v.is("--catch-test") ) unit_test_catch_test_filter(v.get_string()); #endif diff --git a/src/test/unit_test.cc b/src/test/unit_test.cc index 6f4bfee5f..53a92bc55 100644 --- a/src/test/unit_test.cc +++ b/src/test/unit_test.cc @@ -17,60 +17,17 @@ //-------------------------------------------------------------------------- // unit_test.h author Russ Combs +#include +#include + #include #include #include "unit_test.h" -#include - -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" -#endif - -#include - -#if defined(__clang__) -#pragma clang diagnostic pop -#endif -#include - -#include "suite_decl.h" - -static print_output s_mode = CK_LAST; static bool s_catch = false; static std::vector test_tags; -typedef Suite* (* SuiteCtor_f)(); - -static SuiteCtor_f s_suites[] = -{ -#include "suite_list.h" - nullptr -}; - -void unit_test_mode(const char* s) -{ - if ( !s || !strcasecmp(s, UNIT_TEST_MODE_OFF) ) - s_mode = CK_LAST; - - else if ( !strcasecmp(s, UNIT_TEST_MODE_SILENT) ) - s_mode = CK_SILENT; - - else if ( !strcasecmp(s, UNIT_TEST_MODE_MINIMAL) ) - s_mode = CK_MINIMAL; - - else if ( !strcasecmp(s, UNIT_TEST_MODE_NORMAL) ) - s_mode = CK_NORMAL; - - else if ( !strcasecmp(s, UNIT_TEST_MODE_VERBOSE) ) - s_mode = CK_VERBOSE; - - else //if ( !strcasecmp(s, UNIT_TEST_MODE_ENV) ) - s_mode = CK_ENV; -} - void unit_test_catch_test_filter(const char* s) { if ( s && strcmp(s, "all") ) @@ -79,54 +36,11 @@ void unit_test_catch_test_filter(const char* s) s_catch = true; } -bool check_enabled() -{ - return s_mode != CK_LAST; -} - bool catch_enabled() { return s_catch; } -static bool run_check() -{ - int nErr; - SuiteCtor_f* ctor = s_suites; - SRunner* pr = nullptr; - - while ( *ctor ) - { - Suite* ps = (* ctor)(); - - if ( !pr ) - pr = srunner_create(ps); - else - srunner_add_suite(pr, ps); - - ++ctor; - } - if ( !pr ) - return false; - - // tbd - possible to support forking? - srunner_set_fork_status(pr, CK_NOFORK); - - // PrintTests(); - //if ( argc > 1 ) s_debug = 1; - - // srunner_set_log() overrides CK_ENV - const char* log = getenv("CK_LOG"); - if ( log ) - srunner_set_log (pr, log); - - srunner_run_all(pr, s_mode); - nErr = srunner_ntests_failed(pr); - - srunner_free(pr); - return !nErr; -} - // check defines fail, so we must squash that because // catch uses stream and that has a fail method #undef fail @@ -138,8 +52,8 @@ 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( s_mode == CK_VERBOSE ) + // session.configData().showSuccessfulTests = true; if( test_tags.size() > 0 ) session.configData().testsOrTags = test_tags; @@ -147,14 +61,6 @@ static bool run_catch() return session.run() == 0; } -int check_test() -{ - if ( !run_check() ) - return -1; - - return 0; -} - int catch_test() { if ( !run_catch() ) diff --git a/src/test/unit_test.h b/src/test/unit_test.h index 74c7fd357..a0246166d 100644 --- a/src/test/unit_test.h +++ b/src/test/unit_test.h @@ -22,24 +22,10 @@ // Unit test interface -// These are the available arguments to unit_test_mode() -#define UNIT_TEST_MODE_SILENT "silent" -#define UNIT_TEST_MODE_MINIMAL "minimal" -#define UNIT_TEST_MODE_NORMAL "normal" -#define UNIT_TEST_MODE_VERBOSE "verbose" -#define UNIT_TEST_MODE_ENV "env" -#define UNIT_TEST_MODE_OFF "off" - -// Use "env" test mode to allow setting verbosity via this environment variable -#define UNIT_TEST_MODE_ENVVAR "CK_VERBOSITY" - -void unit_test_mode(const char* = nullptr); void unit_test_catch_test_filter(const char* s); -bool check_enabled(); bool catch_enabled(); -int check_test(); int catch_test(); #endif