detect-gid: convert unittests to FAIL/PASS APIs

Bug: #4041
pull/6581/head
Modupe Falodun 5 years ago committed by Victor Julien
parent d581fc82b1
commit a59299d128

@ -1,4 +1,4 @@
/* 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 * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -99,77 +99,50 @@ static int DetectGidSetup (DetectEngineCtx *de_ctx, Signature *s, const char *ra
#ifdef UNITTESTS #ifdef UNITTESTS
/** /**
* \test GidTestParse01 is a test for a valid gid value * \test GidTestParse01 is a test for a valid gid value
*
* \retval 1 on succces
* \retval 0 on failure
*/ */
static int GidTestParse01 (void) static int GidTestParse01 (void)
{ {
int result = 0;
Signature *s = NULL;
DetectEngineCtx *de_ctx = DetectEngineCtxInit(); DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) FAIL_IF_NULL(de_ctx);
goto end;
Signature *s =
s = DetectEngineAppendSig(de_ctx, "alert tcp 1.2.3.4 any -> any any (sid:1; gid:1;)"); DetectEngineAppendSig(de_ctx, "alert tcp 1.2.3.4 any -> any any (sid:1; gid:1;)");
if (s == NULL || s->gid != 1)
goto end; FAIL_IF_NULL(s);
FAIL_IF(s->gid != 1);
result = 1;
end: DetectEngineCtxFree(de_ctx);
if (de_ctx != NULL) PASS;
DetectEngineCtxFree(de_ctx);
return result;
} }
/** /**
* \test GidTestParse02 is a test for an invalid gid value * \test GidTestParse02 is a test for an invalid gid value
*
* \retval 1 on succces
* \retval 0 on failure
*/ */
static int GidTestParse02 (void) static int GidTestParse02 (void)
{ {
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit(); DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) FAIL_IF_NULL(de_ctx);
goto end;
if (DetectEngineAppendSig(de_ctx, "alert tcp 1.2.3.4 any -> any any (sid:1; gid:a;)") != NULL) FAIL_IF_NOT_NULL(
goto end; DetectEngineAppendSig(de_ctx, "alert tcp 1.2.3.4 any -> any any (sid:1; gid:a;)"));
result = 1; DetectEngineCtxFree(de_ctx);
end: PASS;
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
return result;
} }
/** /**
* \test Test a gid consisting of a single quote. * \test Test a gid consisting of a single quote.
*
* \retval 1 on succces
* \retval 0 on failure
*/ */
static int GidTestParse03 (void) static int GidTestParse03 (void)
{ {
int result = 0;
DetectEngineCtx *de_ctx = DetectEngineCtxInit(); DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) FAIL_IF_NULL(de_ctx);
goto end;
FAIL_IF_NOT_NULL(DetectEngineAppendSig(
if (DetectEngineAppendSig(de_ctx, de_ctx, "alert tcp any any -> any any (content:\"ABC\"; gid:\";)"));
"alert tcp any any -> any any (content:\"ABC\"; gid:\";)") != NULL)
goto end; DetectEngineCtxFree(de_ctx);
PASS;
result = 1;
end:
if (de_ctx != NULL)
DetectEngineCtxFree(de_ctx);
return result;
} }
/** /**

Loading…
Cancel
Save