}
#ifdef UNITTESTS
+
+static void HostBitsTestSetup(void)
+{
+ StorageInit();
+ HostBitInitCtx();
+ StorageFinalize();
+ HostInitConfig(TRUE);
+}
+
+static void HostBitsTestShutdown(void)
+{
+ HostCleanup();
+ StorageCleanup();
+}
+
/**
* \test HostBitsTestSig01 is a test for a valid noalert flowbits option
*
DetectEngineCtx *de_ctx = NULL;
int result = 0;
- HostInitConfig(TRUE);
-
memset(&th_v, 0, sizeof(th_v));
memset(p, 0, SIZE_OF_PACKET);
p->src.family = AF_INET;
p->payload_len = buflen;
p->proto = IPPROTO_TCP;
+ HostBitsTestSetup();
+
de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineCtxFree(de_ctx);
}
- HostCleanup();
+ HostBitsTestShutdown();
SCFree(p);
return result;
if (s == NULL) {
error_count++;
}
-
+/* TODO reenable after both is supported
s = DetectEngineAppendSig(de_ctx,
"alert ip any any -> any any (hostbits:set,abc,both; content:\"GET \"; sid:3;)");
if (s == NULL) {
error_count++;
}
-
+*/
s = DetectEngineAppendSig(de_ctx,
"alert ip any any -> any any (hostbits:unset,abc,src; content:\"GET \"; sid:4;)");
if (s == NULL) {
p->payload_len = buflen;
p->proto = IPPROTO_TCP;
+ HostBitsTestSetup();
+
de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
+ HostBitsTestShutdown();
+
SCFree(p);
return result;
DetectEngineCtxFree(de_ctx);
}
+ HostBitsTestShutdown();
+
SCFree(p);
return result;
}
p->payload_len = buflen;
p->proto = IPPROTO_TCP;
+ HostBitsTestSetup();
+
de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
+ HostBitsTestShutdown();
+
SCFree(p);
return result;
end:
DetectEngineCtxFree(de_ctx);
}
+ HostBitsTestShutdown();
+
SCFree(p);
return result;
}
memset(&th_v, 0, sizeof(th_v));
memset(&f, 0, sizeof(Flow));
- HostInitConfig(TRUE);
+ HostBitsTestSetup();
FLOW_INITIALIZE(&f);
p->flow = &f;
FLOW_DESTROY(&f);
- HostCleanup();
-
+ HostBitsTestShutdown();
SCFree(p);
return result;
end:
FLOW_DESTROY(&f);
+ HostBitsTestShutdown();
SCFree(p);
return result;
}
memset(&th_v, 0, sizeof(th_v));
memset(&f, 0, sizeof(Flow));
- HostInitConfig(TRUE);
+ HostBitsTestSetup();
FLOW_INITIALIZE(&f);
p->flow = &f;
FLOW_DESTROY(&f);
- HostCleanup();
+ HostBitsTestShutdown();
SCFree(p);
return result;
FLOW_DESTROY(&f);
+ HostBitsTestShutdown();
+
SCFree(p);
return result;
}