From: Alice Akaki Date: Tue, 18 Oct 2022 16:11:57 +0000 (-0400) Subject: detect-filemagic: convert unittests to FAIL/PASS APIs X-Git-Tag: suricata-7.0.0-beta1~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8614bff0178659bcd2c94e49d3aba50a30fe7844;p=thirdparty%2Fsuricata.git detect-filemagic: convert unittests to FAIL/PASS APIs Task: #4034 --- diff --git a/src/detect-filemagic.c b/src/detect-filemagic.c index cccd44ebb2..b30414a1aa 100644 --- a/src/detect-filemagic.c +++ b/src/detect-filemagic.c @@ -590,11 +590,9 @@ static int PrefilterMpmFilemagicRegister(DetectEngineCtx *de_ctx, static int DetectFilemagicTestParse01 (void) { DetectFilemagicData *dnd = DetectFilemagicParse(NULL, "secret.pdf", false); - if (dnd != NULL) { - DetectFilemagicFree(NULL, dnd); - return 1; - } - return 0; + FAIL_IF_NULL(dnd); + DetectFilemagicFree(NULL, dnd); + PASS; } /** @@ -602,18 +600,12 @@ static int DetectFilemagicTestParse01 (void) */ static int DetectFilemagicTestParse02 (void) { - int result = 0; - DetectFilemagicData *dnd = DetectFilemagicParse(NULL, "backup.tar.gz", false); - if (dnd != NULL) { - if (dnd->len == 13 && memcmp(dnd->name, "backup.tar.gz", 13) == 0) { - result = 1; - } - - DetectFilemagicFree(NULL, dnd); - return result; - } - return 0; + FAIL_IF_NULL(dnd); + FAIL_IF_NOT(dnd->len == 13); + FAIL_IF_NOT(memcmp(dnd->name, "backup.tar.gz", 13) == 0); + DetectFilemagicFree(NULL, dnd); + PASS; } /** @@ -621,18 +613,12 @@ static int DetectFilemagicTestParse02 (void) */ static int DetectFilemagicTestParse03 (void) { - int result = 0; - DetectFilemagicData *dnd = DetectFilemagicParse(NULL, "cmd.exe", false); - if (dnd != NULL) { - if (dnd->len == 7 && memcmp(dnd->name, "cmd.exe", 7) == 0) { - result = 1; - } - - DetectFilemagicFree(NULL, dnd); - return result; - } - return 0; + FAIL_IF_NULL(dnd); + FAIL_IF_NOT(dnd->len == 7); + FAIL_IF_NOT(memcmp(dnd->name, "cmd.exe", 7) == 0); + DetectFilemagicFree(NULL, dnd); + PASS; } /**