-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2021 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
#ifdef UNITTESTS
/**
* \test GidTestParse01 is a test for a valid gid value
- *
- * \retval 1 on succces
- * \retval 0 on failure
*/
static int GidTestParse01 (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->gid != 1)
- goto end;
-
- result = 1;
-end:
- if (de_ctx != NULL)
- DetectEngineCtxFree(de_ctx);
- return result;
+ FAIL_IF_NULL(de_ctx);
+
+ 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->gid != 1);
+
+ DetectEngineCtxFree(de_ctx);
+ PASS;
}
/**
* \test GidTestParse02 is a test for an invalid gid value
- *
- * \retval 1 on succces
- * \retval 0 on failure
*/
static int GidTestParse02 (void)
{
- int result = 0;
-
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
- if (de_ctx == NULL)
- goto end;
+ FAIL_IF_NULL(de_ctx);
- if (DetectEngineAppendSig(de_ctx, "alert tcp 1.2.3.4 any -> any any (sid:1; gid:a;)") != NULL)
- goto end;
+ FAIL_IF_NOT_NULL(
+ DetectEngineAppendSig(de_ctx, "alert tcp 1.2.3.4 any -> any any (sid:1; gid:a;)"));
- result = 1;
-end:
- if (de_ctx != NULL)
- DetectEngineCtxFree(de_ctx);
- return result;
+ DetectEngineCtxFree(de_ctx);
+ PASS;
}
/**
* \test Test a gid consisting of a single quote.
- *
- * \retval 1 on succces
- * \retval 0 on failure
*/
static int GidTestParse03 (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\"; gid:\";)") != 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\"; gid:\";)"));
+
+ DetectEngineCtxFree(de_ctx);
+ PASS;
}
/**