detect/template: clean up unittest

pull/3487/head
Victor Julien 7 years ago
parent b1b45a54c5
commit 234d113838

@ -125,8 +125,8 @@ static int DetectEngineInspectTemplateBuffer(ThreadVars *tv,
static int DetectTemplateBufferTest(void) static int DetectTemplateBufferTest(void)
{ {
AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc();
DetectEngineThreadCtx *det_ctx = NULL; FAIL_IF_NULL(alp_tctx);
DetectEngineCtx *de_ctx = NULL;
Flow f; Flow f;
Packet *p; Packet *p;
TcpSession tcp; TcpSession tcp;
@ -150,7 +150,7 @@ static int DetectTemplateBufferTest(void)
p->flowflags |= FLOW_PKT_TOSERVER | FLOW_PKT_ESTABLISHED; p->flowflags |= FLOW_PKT_TOSERVER | FLOW_PKT_ESTABLISHED;
StreamTcpInitConfig(TRUE); StreamTcpInitConfig(TRUE);
de_ctx = DetectEngineCtxInit(); DetectEngineCtx *de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx); FAIL_IF_NULL(de_ctx);
/* This rule should match. */ /* This rule should match. */
@ -170,7 +170,10 @@ static int DetectTemplateBufferTest(void)
FAIL_IF_NULL(s); FAIL_IF_NULL(s);
SigGroupBuild(de_ctx); SigGroupBuild(de_ctx);
DetectEngineThreadCtx *det_ctx = NULL;
DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx); DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
FAIL_IF_NULL(det_ctx);
FLOWLOCK_WRLOCK(&f); FLOWLOCK_WRLOCK(&f);
AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TEMPLATE, AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TEMPLATE,
@ -185,14 +188,9 @@ static int DetectTemplateBufferTest(void)
FAIL_IF(PacketAlertCheck(p, 2)); FAIL_IF(PacketAlertCheck(p, 2));
/* Cleanup. */ /* Cleanup. */
if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx);
AppLayerParserThreadCtxFree(alp_tctx); DetectEngineThreadCtxDeinit(&tv, det_ctx);
if (det_ctx != NULL) DetectEngineCtxFree(de_ctx);
DetectEngineThreadCtxDeinit(&tv, det_ctx);
if (de_ctx != NULL)
SigGroupCleanup(de_ctx);
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
StreamTcpFreeConfig(TRUE); StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f); FLOW_DESTROY(&f);
UTHFreePacket(p); UTHFreePacket(p);

Loading…
Cancel
Save