detect-tls-cert-validity: clean up unit tests

Remove locks, unnecessary function calls and conditional statements.
pull/2319/head
Mats Klepsland 9 years ago committed by Victor Julien
parent 1fea52dd8a
commit 10d827639e

@ -1259,11 +1259,9 @@ int ValidityTestDetect01(void)
SigGroupBuild(de_ctx);
DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
SCMutexLock(&f.m);
int r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS,
STREAM_TOSERVER, client_hello,
sizeof(client_hello));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1275,10 +1273,8 @@ int ValidityTestDetect01(void)
FAIL_IF(PacketAlertCheck(p1, 1));
FAIL_IF(PacketAlertCheck(p1, 2));
SCMutexLock(&f.m);
r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT,
server_hello, sizeof(server_hello));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1287,10 +1283,8 @@ int ValidityTestDetect01(void)
FAIL_IF(PacketAlertCheck(p2, 1));
FAIL_IF(PacketAlertCheck(p2, 2));
SCMutexLock(&f.m);
r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT,
certificate, sizeof(certificate));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1299,14 +1293,9 @@ int ValidityTestDetect01(void)
FAIL_IF_NOT(PacketAlertCheck(p3, 1));
FAIL_IF_NOT(PacketAlertCheck(p3, 2));
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
if (det_ctx != NULL)
DetectEngineThreadCtxDeinit(&tv, det_ctx);
if (de_ctx != NULL)
SigGroupCleanup(de_ctx);
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
AppLayerParserThreadCtxFree(alp_tctx);
DetectEngineThreadCtxDeinit(&tv, det_ctx);
DetectEngineCtxFree(de_ctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
@ -1598,10 +1587,8 @@ int ExpiredTestDetect01(void)
SigGroupBuild(de_ctx);
DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
SCMutexLock(&f.m);
int r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER,
client_hello, sizeof(client_hello));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1612,10 +1599,8 @@ int ExpiredTestDetect01(void)
FAIL_IF(PacketAlertCheck(p1, 1));
SCMutexLock(&f.m);
r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT,
server_hello, sizeof(server_hello));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1623,10 +1608,8 @@ int ExpiredTestDetect01(void)
FAIL_IF(PacketAlertCheck(p2, 1));
SCMutexLock(&f.m);
r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT,
certificate, sizeof(certificate));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1634,14 +1617,9 @@ int ExpiredTestDetect01(void)
FAIL_IF_NOT(PacketAlertCheck(p3, 1));
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
if (det_ctx != NULL)
DetectEngineThreadCtxDeinit(&tv, det_ctx);
if (de_ctx != NULL)
SigGroupCleanup(de_ctx);
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
AppLayerParserThreadCtxFree(alp_tctx);
DetectEngineThreadCtxDeinit(&tv, det_ctx);
DetectEngineCtxFree(de_ctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);
@ -1918,10 +1896,8 @@ int ValidTestDetect01(void)
SigGroupBuild(de_ctx);
DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
SCMutexLock(&f.m);
int r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS, STREAM_TOSERVER,
client_hello, sizeof(client_hello));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1932,10 +1908,8 @@ int ValidTestDetect01(void)
FAIL_IF(PacketAlertCheck(p1, 1));
SCMutexLock(&f.m);
r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT,
server_hello, sizeof(server_hello));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1943,10 +1917,8 @@ int ValidTestDetect01(void)
FAIL_IF(PacketAlertCheck(p2, 1));
SCMutexLock(&f.m);
r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TLS, STREAM_TOCLIENT,
certificate, sizeof(certificate));
SCMutexUnlock(&f.m);
FAIL_IF(r != 0);
@ -1954,14 +1926,9 @@ int ValidTestDetect01(void)
FAIL_IF_NOT(PacketAlertCheck(p3, 1));
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
if (det_ctx != NULL)
DetectEngineThreadCtxDeinit(&tv, det_ctx);
if (de_ctx != NULL)
SigGroupCleanup(de_ctx);
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
AppLayerParserThreadCtxFree(alp_tctx);
DetectEngineThreadCtxDeinit(&tv, det_ctx);
DetectEngineCtxFree(de_ctx);
StreamTcpFreeConfig(TRUE);
FLOW_DESTROY(&f);

Loading…
Cancel
Save