Go to the documentation of this file.
47 static pcre *parse_regex;
48 static pcre_extra *parse_regex_study;
60 static UtTest *UtAllocTest(
void)
66 memset(ut, 0,
sizeof(
UtTest));
87 while (tmp->
next != NULL) {
105 UtTest *ut = UtAllocTest();
114 UtAppendTest(&ut_list, ut);
125 static int UtRegex (
const char *
regex_arg)
129 int opts = PCRE_CASELESS;;
134 parse_regex = pcre_compile(
regex_arg, opts, &eb, &eo, NULL);
135 if(parse_regex == NULL)
137 printf(
"pcre compile of \"%s\" failed at offset %" PRId32
": %s\n",
regex_arg, eo, eb);
141 parse_regex_study = pcre_study(parse_regex, 0, &eb);
144 printf(
"pcre study failed: %s\n", eb);
154 #define MAX_SUBSTRINGS 30
163 int ret = 0, rcomp = 0;
168 for (ut = ut_list; ut != NULL; ut = ut->
next) {
170 ret = pcre_exec(parse_regex, parse_regex_study, ut->
name,
173 printf(
"%s\n", ut->
name);
177 printf(
"%s\n", ut->
name);
193 uint32_t good = 0, bad = 0, matchcnt = 0;
194 int ret = 0, rcomp = 0;
203 for (ut = ut_list; ut != NULL; ut = ut->
next) {
206 printf(
"Test %-60.60s : ", ut->
name);
230 printf(
"%s\n", ret ?
"pass" :
"FAILED");
234 fprintf(stderr,
"ERROR: unittest failed.\n");
244 printf(
"==== TEST RESULTS ====\n");
245 printf(
"PASSED: %" PRIu32
"\n", good);
246 printf(
"FAILED: %" PRIu32
"\n", bad);
247 printf(
"======================\n");
249 SCLogInfo(
"UtRunTests: regex provided regex_arg: %s did not match any tests",
regex_arg);
252 SCLogInfo(
"UtRunTests: pcre compilation failed");
272 UtTest *tmp = ut_list, *otmp;
274 while (tmp != NULL) {
302 static int UtSelftestTrue(
void)
313 static int UtSelftestFalse(
void)
328 printf(
"* Running Unittesting subsystem selftests...\n");
337 printf(
"* Done running Unittesting subsystem selftests...\n");
339 printf(
"* ERROR running Unittesting subsystem selftests failed...\n");
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
void StreamTcpInitMemuse(void)
void UtListTests(const char *regex_arg)
List all registered unit tests.
int UtRunSelftest(const char *regex_arg)
Run self tests.
uint64_t FlowGetMemuse(void)
void TimeSetToCurrentTime(void)
set the time to "gettimeofday" meant for testing
void UtInitialize(void)
Initialize unit test list.
void StreamTcpReassembleInitMemuse(void)
uint32_t UtRunTests(const char *regex_arg)
Run all registered unittests.
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
void TimeModeSetOffline(void)
void RunModeRegisterNewRunMode(enum RunModes runmode, const char *name, const char *description, int(*RunModeFunc)(void))
Registers a new runmode.
void UtCleanup(void)
Cleanup unit test list.
uint64_t StreamTcpMemuseCounter(void)
uint64_t StreamTcpReassembleMemuseGlobalCounter(void)
void UtRunModeRegister(void)