]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-fileext: convert unittests to FAIL/PASS APIs
authorHaleema Khan <hsadia538@gmail.com>
Thu, 13 Oct 2022 02:23:30 +0000 (07:23 +0500)
committerVictor Julien <vjulien@oisf.net>
Thu, 13 Oct 2022 09:25:42 +0000 (11:25 +0200)
Fixes Bug: #4033

src/detect-fileext.c

index 12aa0f9202e91c464fc58f9399b2a586f66e6f57..80f1d71ab904aecab24048d7de16ad9161977775 100644 (file)
@@ -253,11 +253,10 @@ static void DetectFileextFree(DetectEngineCtx *de_ctx, void *ptr)
 static int DetectFileextTestParse01 (void)
 {
     DetectFileextData *dfd = DetectFileextParse(NULL, "doc", false);
-    if (dfd != NULL) {
-        DetectFileextFree(NULL, dfd);
-        return 1;
-    }
-    return 0;
+    FAIL_IF_NULL(dfd);
+    DetectFileextFree(NULL, dfd);
+
+    PASS;
 }
 
 /**
@@ -265,18 +264,13 @@ static int DetectFileextTestParse01 (void)
  */
 static int DetectFileextTestParse02 (void)
 {
-    int result = 0;
-
     DetectFileextData *dfd = DetectFileextParse(NULL, "tar.gz", false);
-    if (dfd != NULL) {
-        if (dfd->len == 6 && memcmp(dfd->ext, "tar.gz", 6) == 0) {
-            result = 1;
-        }
+    FAIL_IF_NULL(dfd);
+    FAIL_IF_NOT(dfd->len == 6);
+    FAIL_IF_NOT(memcmp(dfd->ext, "tar.gz", 6) == 0);
+    DetectFileextFree(NULL, dfd);
 
-        DetectFileextFree(NULL, dfd);
-        return result;
-    }
-    return 0;
+    PASS;
 }
 
 /**
@@ -284,18 +278,13 @@ static int DetectFileextTestParse02 (void)
  */
 static int DetectFileextTestParse03 (void)
 {
-    int result = 0;
-
     DetectFileextData *dfd = DetectFileextParse(NULL, "pdf", false);
-    if (dfd != NULL) {
-        if (dfd->len == 3 && memcmp(dfd->ext, "pdf", 3) == 0) {
-            result = 1;
-        }
+    FAIL_IF_NULL(dfd);
+    FAIL_IF_NOT(dfd->len == 3);
+    FAIL_IF_NOT(memcmp(dfd->ext, "pdf", 3) == 0);
+    DetectFileextFree(NULL, dfd);
 
-        DetectFileextFree(NULL, dfd);
-        return result;
-    }
-    return 0;
+    PASS;
 }
 
 /**