"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,
- "<verbosity> 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
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
//--------------------------------------------------------------------------
// unit_test.h author Russ Combs <rucombs@cisco.com>
+#include <stdlib.h>
+#include <string.h>
+
#include <vector>
#include <string>
#include "unit_test.h"
-#include <stdlib.h>
-
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
-#endif
-
-#include <check.h>
-
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-#include <check.h>
-
-#include "suite_decl.h"
-
-static print_output s_mode = CK_LAST;
static bool s_catch = false;
static std::vector<std::string> 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") )
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
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;
return session.run() == 0;
}
-int check_test()
-{
- if ( !run_check() )
- return -1;
-
- return 0;
-}
-
int catch_test()
{
if ( !run_catch() )
// 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