]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-sid: fail/pass api
authorJuliana Fajardini <jufajardini@gmail.com>
Mon, 16 Nov 2020 19:49:56 +0000 (19:49 +0000)
committerVictor Julien <victor@inliniac.net>
Wed, 9 Dec 2020 14:13:48 +0000 (15:13 +0100)
- convert unittests to new FAIL/PASS API.

src/detect-sid.c

index 2c0323b594e80bbcf7857ae4a0d8a15bfdd78780..979a663ccfcef553d5d4d2c35df0f2604a64f101 100644 (file)
@@ -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;
 }
 
 /**