iponly: fix unittests

pull/2250/head
Victor Julien 9 years ago
parent 215d0d54c7
commit f1117ba2dc

@ -1561,25 +1561,17 @@ void IPOnlyAddSignature(DetectEngineCtx *de_ctx, DetectEngineIPOnlyCtx *io_ctx,
static int IPOnlyTestSig01(void) static int IPOnlyTestSig01(void)
{ {
int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit();
DetectEngineCtx de_ctx; FAIL_IF(de_ctx == NULL);
de_ctx->flags |= DE_QUIET;
memset(&de_ctx, 0, sizeof(DetectEngineCtx));
de_ctx.flags |= DE_QUIET;
Signature *s = SigInit(&de_ctx,"alert tcp any any -> any any (msg:\"SigTest40-01 sig is IPOnly \"; sid:400001; rev:1;)"); Signature *s = SigInit(de_ctx,"alert tcp any any -> any any (sid:400001; rev:1;)");
if (s == NULL) { FAIL_IF(s == NULL);
goto end;
}
if(SignatureIsIPOnly(&de_ctx, s))
result = 1;
else
printf("expected a IPOnly signature: ");
FAIL_IF(SignatureIsIPOnly(de_ctx, s) == 0);
SigFree(s); SigFree(s);
end: DetectEngineCtxFree(de_ctx);
return result; PASS;
} }
/** /**
@ -1589,27 +1581,17 @@ end:
static int IPOnlyTestSig02 (void) static int IPOnlyTestSig02 (void)
{ {
int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit();
DetectEngineCtx de_ctx; FAIL_IF(de_ctx == NULL);
memset (&de_ctx, 0, sizeof(DetectEngineCtx)); de_ctx->flags |= DE_QUIET;
memset(&de_ctx, 0, sizeof(DetectEngineCtx));
de_ctx.flags |= DE_QUIET; Signature *s = SigInit(de_ctx,"alert tcp any any -> any 80 (sid:400001; rev:1;)");
FAIL_IF(s == NULL);
Signature *s = SigInit(&de_ctx,"alert tcp any any -> any 80 (msg:\"SigTest40-02 sig is not IPOnly \"; sid:400001; rev:1;)");
if (s == NULL) {
goto end;
}
if ((SignatureIsIPOnly(&de_ctx, s)))
result = 1;
else
printf("got a non-IPOnly signature: ");
FAIL_IF(SignatureIsIPOnly(de_ctx, s) == 0);
SigFree(s); SigFree(s);
DetectEngineCtxFree(de_ctx);
end: PASS;
return result;
} }
/** /**
@ -2119,52 +2101,36 @@ int IPOnlyTestSig12(void)
static int IPOnlyTestSig13(void) static int IPOnlyTestSig13(void)
{ {
int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit();
DetectEngineCtx de_ctx; FAIL_IF(de_ctx == NULL);
de_ctx->flags |= DE_QUIET;
memset(&de_ctx, 0, sizeof(DetectEngineCtx));
de_ctx.flags |= DE_QUIET;
Signature *s = SigInit(&de_ctx, Signature *s = SigInit(de_ctx,
"alert tcp any any -> any any (msg:\"Test flowbits ip only\"; " "alert tcp any any -> any any (msg:\"Test flowbits ip only\"; "
"flowbits:set,myflow1; sid:1; rev:1;)"); "flowbits:set,myflow1; sid:1; rev:1;)");
if (s == NULL) { FAIL_IF(s == NULL);
goto end;
}
if (SignatureIsIPOnly(&de_ctx, s))
result = 1;
else
printf("expected a IPOnly signature: ");
FAIL_IF(SignatureIsIPOnly(de_ctx, s) == 0);
SigFree(s); SigFree(s);
end: DetectEngineCtxFree(de_ctx);
return result; PASS;
} }
static int IPOnlyTestSig14(void) static int IPOnlyTestSig14(void)
{ {
int result = 0; DetectEngineCtx *de_ctx = DetectEngineCtxInit();
DetectEngineCtx de_ctx; FAIL_IF(de_ctx == NULL);
de_ctx->flags |= DE_QUIET;
memset(&de_ctx, 0, sizeof(DetectEngineCtx));
de_ctx.flags |= DE_QUIET;
Signature *s = SigInit(&de_ctx, Signature *s = SigInit(de_ctx,
"alert tcp any any -> any any (msg:\"Test flowbits ip only\"; " "alert tcp any any -> any any (msg:\"Test flowbits ip only\"; "
"flowbits:set,myflow1; flowbits:isset,myflow2; sid:1; rev:1;)"); "flowbits:set,myflow1; flowbits:isset,myflow2; sid:1; rev:1;)");
if (s == NULL) { FAIL_IF(s == NULL);
goto end;
}
if (SignatureIsIPOnly(&de_ctx, s))
printf("expected a IPOnly signature: ");
else
result = 1;
FAIL_IF(SignatureIsIPOnly(de_ctx, s) == 1);
SigFree(s); SigFree(s);
end: DetectEngineCtxFree(de_ctx);
return result; PASS;
} }
int IPOnlyTestSig15(void) int IPOnlyTestSig15(void)

Loading…
Cancel
Save