From: Alice Akaki Date: Mon, 17 Oct 2022 21:44:15 +0000 (-0400) Subject: detect-filename: convert unittests to FAIL/PASS APIs X-Git-Tag: suricata-7.0.0-beta1~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76024f757112ec92153c6276d70d3ac05f1ac651;p=thirdparty%2Fsuricata.git detect-filename: convert unittests to FAIL/PASS APIs Task: #4036 --- diff --git a/src/detect-filename.c b/src/detect-filename.c index e953b03dbe..4ad6fab867 100644 --- a/src/detect-filename.c +++ b/src/detect-filename.c @@ -505,11 +505,9 @@ static int DetectFilenameSignatureParseTest01(void) static int DetectFilenameTestParse01 (void) { DetectFilenameData *dnd = DetectFilenameParse(NULL, "secret.pdf", false); - if (dnd != NULL) { - DetectFilenameFree(NULL, dnd); - return 1; - } - return 0; + FAIL_IF_NULL(dnd); + DetectFilenameFree(NULL, dnd); + PASS; } /** @@ -517,18 +515,12 @@ static int DetectFilenameTestParse01 (void) */ static int DetectFilenameTestParse02 (void) { - int result = 0; - DetectFilenameData *dnd = DetectFilenameParse(NULL, "backup.tar.gz", false); - if (dnd != NULL) { - if (dnd->len == 13 && memcmp(dnd->name, "backup.tar.gz", 13) == 0) { - result = 1; - } - - DetectFilenameFree(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); + DetectFilenameFree(NULL, dnd); + PASS; } /** @@ -536,21 +528,14 @@ static int DetectFilenameTestParse02 (void) */ static int DetectFilenameTestParse03 (void) { - int result = 0; - DetectFilenameData *dnd = DetectFilenameParse(NULL, "cmd.exe", false); - if (dnd != NULL) { - if (dnd->len == 7 && memcmp(dnd->name, "cmd.exe", 7) == 0) { - result = 1; - } - - DetectFilenameFree(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); + DetectFilenameFree(NULL, dnd); + PASS; } - /** * \brief this function registers unit tests for DetectFilename */