From b31a28695286a14d9ed640f816cdafc0b6d7503f Mon Sep 17 00:00:00 2001 From: Haleema Khan Date: Thu, 13 Oct 2022 07:23:30 +0500 Subject: [PATCH] detect-fileext: convert unittests to FAIL/PASS APIs Fixes Bug: #4033 --- src/detect-fileext.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/src/detect-fileext.c b/src/detect-fileext.c index 12aa0f9202..80f1d71ab9 100644 --- a/src/detect-fileext.c +++ b/src/detect-fileext.c @@ -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; } /**