47static pcre2_code *parse_regex;
48static pcre2_match_data *parse_regex_match;
60static UtTest *UtAllocTest(
void)
66 memset(ut, 0,
sizeof(
UtTest));
87 while (tmp->
next != NULL) {
105 UtTest *ut = UtAllocTest();
114 UtAppendTest(&ut_list, ut);
125static int UtRegex (
const char *
regex_arg)
129 int opts = PCRE2_CASELESS;
135 pcre2_compile((PCRE2_SPTR8)
regex_arg, PCRE2_ZERO_TERMINATED, opts, &en, &eo, NULL);
136 if(parse_regex == NULL)
138 PCRE2_UCHAR errbuffer[256];
139 pcre2_get_error_message(en, errbuffer,
sizeof(errbuffer));
140 SCLogError(
"pcre2 compile of \"%s\" failed at "
145 parse_regex_match = pcre2_match_data_create_from_pattern(parse_regex, NULL);
160 int ret = 0, rcomp = 0;
164 for (ut = ut_list; ut != NULL; ut = ut->
next) {
166 ret = pcre2_match(parse_regex, (PCRE2_SPTR8)ut->
name, strlen(ut->
name), 0, 0,
167 parse_regex_match, NULL);
169 printf(
"%s\n", ut->
name);
173 printf(
"%s\n", ut->
name);
176 pcre2_code_free(parse_regex);
177 pcre2_match_data_free(parse_regex_match);
191 uint32_t good = 0, bad = 0, matchcnt = 0;
192 int ret = 0, rcomp = 0;
200 for (ut = ut_list; ut != NULL; ut = ut->
next) {
201 ret = pcre2_match(parse_regex, (PCRE2_SPTR8)ut->
name, strlen(ut->
name), 0, 0,
202 parse_regex_match, NULL);
204 printf(
"Test %-60.60s : ", ut->
name);
228 printf(
"%s\n", ret ?
"pass" :
"FAILED");
232 fprintf(stderr,
"ERROR: unittest failed.\n");
242 printf(
"==== TEST RESULTS ====\n");
243 printf(
"PASSED: %" PRIu32
"\n", good);
244 printf(
"FAILED: %" PRIu32
"\n", bad);
245 printf(
"======================\n");
247 SCLogInfo(
"UtRunTests: regex provided regex_arg: %s did not match any tests",
regex_arg);
250 SCLogInfo(
"UtRunTests: pcre compilation failed");
252 pcre2_code_free(parse_regex);
253 pcre2_match_data_free(parse_regex_match);
272 UtTest *tmp = ut_list, *otmp;
274 while (tmp != NULL) {
297static int UtSelftestTrue(
void)
308static int UtSelftestFalse(
void)
323 printf(
"* Running Unittesting subsystem selftests...\n");
332 printf(
"* Done running Unittesting subsystem selftests...\n");
334 printf(
"* ERROR running Unittesting subsystem selftests failed...\n");
uint64_t FlowGetMemuse(void)
int UtRunSelftest(const char *regex_arg)
Run self tests.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
void UtCleanup(void)
Cleanup unit test list.
void UtRunModeRegister(void)
void UtInitialize(void)
Initialize unit test list.
uint32_t UtRunTests(const char *regex_arg)
Run all registered unittests.
void UtListTests(const char *regex_arg)
List all registered unit tests.
void RunModeRegisterNewRunMode(enum SCRunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void), int(*RunModeIsIPSEnabled)(void))
Registers a new runmode.
uint64_t StreamTcpReassembleMemuseGlobalCounter(void)
void StreamTcpReassembleInitMemuse(void)
void StreamTcpInitMemuse(void)
uint64_t StreamTcpMemuseCounter(void)
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
#define SCLogError(...)
Macro used to log ERROR messages.
void TimeSetToCurrentTime(void)
set the time to "gettimeofday" meant for testing
void TimeModeSetOffline(void)