]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-template: modernize 2222/head
authorVictor Julien <victor@inliniac.net>
Fri, 2 Sep 2016 10:47:11 +0000 (12:47 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 5 Sep 2016 16:16:35 +0000 (18:16 +0200)
src/detect-template.c
src/detect-template.h

index b415783a60f92a7494ff036fc3f288df4fa1368d..b3ffb08e79415e876eed34f3c4086fc6369886fe 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015 Open Information Security Foundation
+/* Copyright (C) 2015-2016 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -229,40 +229,25 @@ static void DetectTemplateFree(void *ptr) {
  * \test description of the test
  */
 
-static int DetectTemplateParseTest01 (void) {
-    DetectTemplateData *templated = NULL;
-    uint8_t res = 0;
-
-    templated = DetectTemplateParse("1,10");
-    if (templated != NULL) {
-        if (templated->arg1 == 1 && templated->arg2 == 10)
-            res = 1;
-
-        DetectTemplateFree(templated);
-    }
-
-    return res;
+static int DetectTemplateParseTest01 (void)
+{
+    DetectTemplateData *templated = DetectTemplateParse("1,10");
+    FAIL_IF_NULL(templated);
+    FAIL_IF(!(templated->arg1 == 1 && templated->arg2 == 10));
+    DetectTemplateFree(templated);
+    PASS;
 }
 
-static int DetectTemplateSignatureTest01 (void) {
-    uint8_t res = 0;
-
+static int DetectTemplateSignatureTest01 (void)
+{
     DetectEngineCtx *de_ctx = DetectEngineCtxInit();
-    if (de_ctx == NULL)
-        goto end;
+    FAIL_IF_NULL(de_ctx);
 
     Signature *sig = DetectEngineAppendSig(de_ctx, "alert ip any any -> any any (template:1,10; sid:1; rev:1;)");
-    if (sig == NULL) {
-        printf("parsing signature failed: ");
-        goto end;
-    }
+    FAIL_IF_NULL(sig);
 
-    /* if we get here, all conditions pass */
-    res = 1;
-end:
-    if (de_ctx != NULL)
-        DetectEngineCtxFree(de_ctx);
-    return res;
+    DetectEngineCtxFree(de_ctx);
+    PASS;
 }
 
 #endif /* UNITTESTS */
index d86c0083bb6e34f8a262ad7ae41c2fc6e44987ec..6b2b4435ef80310b39a89b9fdfc3a7ee867ae251 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015 Open Information Security Foundation
+/* Copyright (C) 2015-2016 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free