Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect-engine: convert unittests to FAIL/PASS APIs v2 #6525

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 40 additions & 65 deletions src/detect-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -4302,23 +4302,19 @@ static int DetectEngineTest01(void)
" - inspection-recursion-limit: 0\n";

DetectEngineCtx *de_ctx = NULL;
int result = 0;

if (DetectEngineInitYamlConf(conf) == -1)
return 0;
FAIL_IF(DetectEngineInitYamlConf(conf) == -1);

de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL)
goto end;
FAIL_IF_NULL(de_ctx);

result = (de_ctx->inspection_recursion_limit == -1);
FAIL_IF(!(de_ctx->inspection_recursion_limit == -1));
ghostinthehive marked this conversation as resolved.
Show resolved Hide resolved

end:
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
DetectEngineCtxFree(de_ctx);

DetectEngineDeInitYamlConf();

return result;
PASS;
}

static int DetectEngineTest02(void)
Expand All @@ -4340,23 +4336,20 @@ static int DetectEngineTest02(void)
" - inspection-recursion-limit:\n";

DetectEngineCtx *de_ctx = NULL;
int result = 0;

if (DetectEngineInitYamlConf(conf) == -1)
return 0;
FAIL_IF(DetectEngineInitYamlConf(conf) == -1);

de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL)
goto end;
FAIL_IF_NULL(de_ctx);

result = (de_ctx->inspection_recursion_limit == DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT);
FAIL_IF(!(de_ctx->inspection_recursion_limit ==
DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT));

end:
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
DetectEngineCtxFree(de_ctx);

DetectEngineDeInitYamlConf();

return result;
PASS;
}

static int DetectEngineTest03(void)
Expand All @@ -4377,24 +4370,20 @@ static int DetectEngineTest03(void)
" toserver_dp_groups: 25\n";

DetectEngineCtx *de_ctx = NULL;
int result = 0;

if (DetectEngineInitYamlConf(conf) == -1)
return 0;
FAIL_IF(DetectEngineInitYamlConf(conf) == -1);

de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL)
goto end;
FAIL_IF_NULL(de_ctx);

result = (de_ctx->inspection_recursion_limit ==
DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT);
FAIL_IF(!(de_ctx->inspection_recursion_limit ==
DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT));

end:
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
DetectEngineCtxFree(de_ctx);

DetectEngineDeInitYamlConf();

return result;
PASS;
}

static int DetectEngineTest04(void)
Expand All @@ -4416,23 +4405,19 @@ static int DetectEngineTest04(void)
" - inspection-recursion-limit: 10\n";

DetectEngineCtx *de_ctx = NULL;
int result = 0;

if (DetectEngineInitYamlConf(conf) == -1)
return 0;
FAIL_IF(DetectEngineInitYamlConf(conf) == -1);

de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL)
goto end;
FAIL_IF_NULL(de_ctx);

result = (de_ctx->inspection_recursion_limit == 10);
FAIL_IF(!(de_ctx->inspection_recursion_limit == 10));

end:
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
DetectEngineCtxFree(de_ctx);

DetectEngineDeInitYamlConf();

return result;
PASS;
}

static int DetectEngineTest08(void)
Expand All @@ -4447,25 +4432,20 @@ static int DetectEngineTest08(void)
" toserver-groups: 27\n";

DetectEngineCtx *de_ctx = NULL;
int result = 0;

if (DetectEngineInitYamlConf(conf) == -1)
return 0;
FAIL_IF(DetectEngineInitYamlConf(conf) == -1);

de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL)
goto end;
FAIL_IF_NULL(de_ctx);

if (de_ctx->max_uniq_toclient_groups == 23 &&
de_ctx->max_uniq_toserver_groups == 27)
result = 1;
FAIL_IF(!(de_ctx->max_uniq_toclient_groups == 23 &&
de_ctx->max_uniq_toserver_groups == 27));

end:
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
DetectEngineCtxFree(de_ctx);

DetectEngineDeInitYamlConf();

return result;
PASS;
}

/** \test bug 892 bad values */
Expand All @@ -4482,25 +4462,20 @@ static int DetectEngineTest09(void)
" - inspection-recursion-limit: 10\n";

DetectEngineCtx *de_ctx = NULL;
int result = 0;

if (DetectEngineInitYamlConf(conf) == -1)
return 0;
FAIL_IF(DetectEngineInitYamlConf(conf) == -1);

de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL)
goto end;
FAIL_IF_NULL(de_ctx);

if (de_ctx->max_uniq_toclient_groups == 20 &&
de_ctx->max_uniq_toserver_groups == 40)
result = 1;
FAIL_IF(!(de_ctx->max_uniq_toclient_groups == 20 &&
de_ctx->max_uniq_toserver_groups == 40));

end:
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
DetectEngineCtxFree(de_ctx);

DetectEngineDeInitYamlConf();

return result;
PASS;
}

#endif
Expand Down