From: Jason Ish Date: Thu, 7 Apr 2016 16:57:45 +0000 (-0600) Subject: flowbits: use some of the new test macros X-Git-Tag: suricata-3.1RC1~284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52f6d214631199fcf5371f55e1dfb0fff3a6afe4;p=thirdparty%2Fsuricata.git flowbits: use some of the new test macros --- diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index 6853f323fb..5cc727c3e7 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -315,69 +315,38 @@ void DetectFlowbitFree (void *ptr) static int FlowBitsTestParse01(void) { - int ret = 0; char command[16] = "", name[16] = ""; /* Single argument version. */ - if (!DetectFlowbitParse("noalert", command, sizeof(command), name, - sizeof(name))) { - goto end; - } - if (strcmp(command, "noalert") != 0) { - goto end; - } + FAIL_IF(!DetectFlowbitParse("noalert", command, sizeof(command), name, + sizeof(name))); + FAIL_IF(strcmp(command, "noalert") != 0); /* No leading or trailing spaces. */ - if (!DetectFlowbitParse("set,flowbit", command, sizeof(command), name, - sizeof(name))) { - goto end; - } - if (strcmp(command, "set") != 0) { - goto end; - } - if (strcmp(name, "flowbit") != 0) { - goto end; - } + FAIL_IF(!DetectFlowbitParse("set,flowbit", command, sizeof(command), name, + sizeof(name))); + FAIL_IF(strcmp(command, "set") != 0); + FAIL_IF(strcmp(name, "flowbit") != 0); /* Leading space. */ - if (!DetectFlowbitParse("set, flowbit", command, sizeof(command), name, - sizeof(name))) { - goto end; - } - if (strcmp(command, "set") != 0) { - goto end; - } - if (strcmp(name, "flowbit") != 0) { - goto end; - } + FAIL_IF(!DetectFlowbitParse("set, flowbit", command, sizeof(command), name, + sizeof(name))); + FAIL_IF(strcmp(command, "set") != 0); + FAIL_IF(strcmp(name, "flowbit") != 0); /* Trailing space. */ - if (!DetectFlowbitParse("set,flowbit ", command, sizeof(command), name, - sizeof(name))) { - goto end; - } - if (strcmp(command, "set") != 0) { - goto end; - } - if (strcmp(name, "flowbit") != 0) { - goto end; - } + FAIL_IF(!DetectFlowbitParse("set,flowbit ", command, sizeof(command), name, + sizeof(name))); + FAIL_IF(strcmp(command, "set") != 0); + FAIL_IF(strcmp(name, "flowbit") != 0); /* Leading and trailing space. */ - if (!DetectFlowbitParse("set, flowbit ", command, sizeof(command), name, - sizeof(name))) { - goto end; - } - if (strcmp(command, "set") != 0) { - goto end; - } - if (strcmp(name, "flowbit") != 0) { - goto end; - } + FAIL_IF(!DetectFlowbitParse("set, flowbit ", command, sizeof(command), name, + sizeof(name))); + FAIL_IF(strcmp(command, "set") != 0); + FAIL_IF(strcmp(name, "flowbit") != 0); - ret = 1; -end: - return ret; + PASS; } /** @@ -452,7 +421,7 @@ end: } SCFree(p); - return result == 0; + PASS_IF(result == 0); } /** @@ -574,7 +543,7 @@ end: } SCFree(p); - return result == 0; + PASS_IF(result == 0); } /** @@ -652,7 +621,7 @@ end: SCFree(p); - return result == 0; + PASS_IF(result == 0); } /** @@ -716,7 +685,7 @@ static int FlowBitsTestSig04(void) DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); SCFree(p); - return result; + PASS_IF(result); end: @@ -734,7 +703,7 @@ end: } SCFree(p); - return result; + PASS_IF(result); } /** @@ -796,7 +765,7 @@ static int FlowBitsTestSig05(void) DetectEngineCtxFree(de_ctx); SCFree(p); - return result; + PASS_IF(result); end: if (de_ctx != NULL) { @@ -813,7 +782,7 @@ end: } SCFree(p); - return result; + PASS_IF(result); } /** @@ -898,7 +867,7 @@ static int FlowBitsTestSig06(void) FLOW_DESTROY(&f); SCFree(p); - return result; + PASS_IF(result); end: if (de_ctx != NULL) { @@ -917,7 +886,7 @@ end: if(gv) GenericVarFree(gv); FLOW_DESTROY(&f); SCFree(p); - return result; + PASS_IF(result); } /** @@ -1004,7 +973,7 @@ static int FlowBitsTestSig07(void) FLOW_DESTROY(&f); SCFree(p); - return result == 0; + PASS_IF(result == 0); end: if (de_ctx != NULL) { @@ -1024,7 +993,7 @@ end: FLOW_DESTROY(&f); SCFree(p); - return result == 0; + PASS_IF(result == 0); } /** @@ -1113,7 +1082,7 @@ static int FlowBitsTestSig08(void) FLOW_DESTROY(&f); SCFree(p); - return result == 0; + PASS_IF(result == 0); end: if (de_ctx != NULL) { @@ -1133,7 +1102,7 @@ end: FLOW_DESTROY(&f); SCFree(p); - return result == 0; + PASS_IF(result == 0); } #endif /* UNITTESTS */