static int AlertFastLogTest01(void)
{
- int result = 0;
uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n"
"Host: one.example.org\r\n";
p = UTHBuildPacket(buf, buflen, IPPROTO_TCP);
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
- if (de_ctx == NULL) {
- return result;
- }
+ FAIL_IF(de_ctx == NULL);
de_ctx->flags |= DE_QUIET;
DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
- if (p->alerts.cnt == 1) {
- result = (strcmp(p->alerts.alerts[0].s->class_msg, "Unknown are we") == 0);
- }
+ FAIL_IF_NOT(p->alerts.cnt == 1);
+ FAIL_IF_NOT(strcmp(p->alerts.alerts[0].s->class_msg, "Unknown are we") == 0);
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
DetectEngineCtxFree(de_ctx);
UTHFreePackets(&p, 1);
- return result;
+ PASS;
}
static int AlertFastLogTest02(void)
{
- int result = 0;
uint8_t *buf = (uint8_t *) "GET /one/ HTTP/1.1\r\n"
"Host: one.example.org\r\n";
uint16_t buflen = strlen((char *)buf);
p = UTHBuildPacket(buf, buflen, IPPROTO_TCP);
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
- if (de_ctx == NULL) {
- return result;
- }
+ FAIL_IF(de_ctx == NULL);
de_ctx->flags |= DE_QUIET;
DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
SigMatchSignatures(&th_v, de_ctx, det_ctx, p);
- if (p->alerts.cnt == 1) {
- result = (strcmp(p->alerts.alerts[0].s->class_msg,
- "Unknown are we") == 0);
- if (result == 0)
- printf("p->alerts.alerts[0].class_msg %s: ", p->alerts.alerts[0].s->class_msg);
- }
+ FAIL_IF_NOT(p->alerts.cnt == 1);
+ FAIL_IF_NOT(strcmp(p->alerts.alerts[0].s->class_msg, "Unknown are we") == 0);
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
DetectEngineCtxFree(de_ctx);
UTHFreePackets(&p, 1);
- return result;
+ PASS;
}
#endif /* UNITTESTS */