From: Juliana Fajardini Date: Mon, 16 Nov 2020 19:49:56 +0000 (+0000) Subject: detect-sid: fail/pass api X-Git-Tag: suricata-7.0.0-beta1~1947 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2144c0dfb91662e8e5b1ea79deccc7b1364887b;p=thirdparty%2Fsuricata.git detect-sid: fail/pass api - convert unittests to new FAIL/PASS API. --- diff --git a/src/detect-sid.c b/src/detect-sid.c index 2c0323b594..979a663ccf 100644 --- a/src/detect-sid.c +++ b/src/detect-sid.c @@ -83,63 +83,40 @@ static int DetectSidSetup (DetectEngineCtx *de_ctx, Signature *s, const char *si static int SidTestParse01(void) { - int result = 0; - Signature *s = NULL; - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - if (de_ctx == NULL) - goto end; - - s = DetectEngineAppendSig(de_ctx, - "alert tcp 1.2.3.4 any -> any any (sid:1; gid:1;)"); - if (s == NULL || s->id != 1) - goto end; + FAIL_IF_NULL(de_ctx); - result = 1; + Signature *s = + DetectEngineAppendSig(de_ctx, "alert tcp 1.2.3.4 any -> any any (sid:1; gid:1;)"); + FAIL_IF_NULL(s); + FAIL_IF(s->id != 1); -end: - if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); - return result; + DetectEngineCtxFree(de_ctx); + PASS; } static int SidTestParse02(void) { - int result = 0; - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - if (de_ctx == NULL) - goto end; - - if (DetectEngineAppendSig(de_ctx, - "alert tcp 1.2.3.4 any -> any any (sid:a; gid:1;)") != NULL) - goto end; + FAIL_IF_NULL(de_ctx); - result = 1; + FAIL_IF_NOT_NULL( + DetectEngineAppendSig(de_ctx, "alert tcp 1.2.3.4 any -> any any (sid:a; gid:1;)")); -end: - if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); - return result; + DetectEngineCtxFree(de_ctx); + PASS; } static int SidTestParse03(void) { - int result = 0; - DetectEngineCtx *de_ctx = DetectEngineCtxInit(); - if (de_ctx == NULL) - goto end; - - if (DetectEngineAppendSig(de_ctx, - "alert tcp any any -> any any (content:\"ABC\"; sid:\";)") != NULL) - goto end; - - result = 1; -end: - if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); - return result; + FAIL_IF_NULL(de_ctx); + + FAIL_IF_NOT_NULL(DetectEngineAppendSig( + de_ctx, "alert tcp any any -> any any (content:\"ABC\"; sid:\";)")); + + DetectEngineCtxFree(de_ctx); + PASS; } /**