From: Steven Ottenhoff Date: Thu, 13 Jan 2022 12:38:01 +0000 (+0000) Subject: test/pppoe: refactor to use FAIL/PASS macros X-Git-Tag: suricata-7.0.0-beta1~1056 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=260bc03603808b848891e9cfe1737d8468a16232;p=thirdparty%2Fsuricata.git test/pppoe: refactor to use FAIL/PASS macros --- diff --git a/src/decode-pppoe.c b/src/decode-pppoe.c index fe49f22d64..757a276211 100644 --- a/src/decode-pppoe.c +++ b/src/decode-pppoe.c @@ -243,7 +243,7 @@ static int DecodePPPOEtest01 (void) uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x00, 0x00 }; Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) - return 0; + FAIL; ThreadVars tv; DecodeThreadVars dtv; @@ -252,13 +252,13 @@ static int DecodePPPOEtest01 (void) DecodePPPOESession(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe)); - if (ENGINE_ISSET_EVENT(p,PPPOE_PKT_TOO_SMALL)) { + if (!ENGINE_ISSET_EVENT(p, PPPOE_PKT_TOO_SMALL)) { SCFree(p); - return 1; + FAIL; } SCFree(p); - return 0; + PASS; } /** DecodePPPOEtest02 @@ -281,7 +281,7 @@ static int DecodePPPOEtest02 (void) Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) - return 0; + FAIL; ThreadVars tv; DecodeThreadVars dtv; int ret = 0; @@ -307,7 +307,8 @@ static int DecodePPPOEtest02 (void) end: FlowShutdown(); SCFree(p); - return ret; + FAIL_IF(ret == 0); + PASS; } @@ -329,7 +330,7 @@ static int DecodePPPOEtest03 (void) Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) - return 0; + FAIL; ThreadVars tv; DecodeThreadVars dtv; @@ -339,11 +340,11 @@ static int DecodePPPOEtest03 (void) DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe)); if (p->pppoedh == NULL) { SCFree(p); - return 0; + FAIL; } SCFree(p); - return 1; + PASS; } /** DecodePPPOEtest04 @@ -361,7 +362,7 @@ static int DecodePPPOEtest04 (void) Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) - return 0; + FAIL; ThreadVars tv; DecodeThreadVars dtv; @@ -370,13 +371,13 @@ static int DecodePPPOEtest04 (void) DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe)); - if(ENGINE_ISSET_EVENT(p,PPPOE_WRONG_CODE)) { + if (!ENGINE_ISSET_EVENT(p, PPPOE_WRONG_CODE)) { SCFree(p); - return 1; + FAIL; } SCFree(p); - return 0; + PASS; } /** DecodePPPOEtest05 @@ -396,7 +397,7 @@ static int DecodePPPOEtest05 (void) Packet *p = PacketGetFromAlloc(); if (unlikely(p == NULL)) - return 0; + FAIL; ThreadVars tv; DecodeThreadVars dtv; @@ -405,13 +406,13 @@ static int DecodePPPOEtest05 (void) DecodePPPOEDiscovery(&tv, &dtv, p, raw_pppoe, sizeof(raw_pppoe)); - if(ENGINE_ISSET_EVENT(p,PPPOE_MALFORMED_TAGS)) { + if (!ENGINE_ISSET_EVENT(p, PPPOE_MALFORMED_TAGS)) { SCFree(p); - return 1; + FAIL; } SCFree(p); - return 0; + PASS; } /** DecodePPPOEtest06 @@ -430,22 +431,21 @@ static int DecodePPPOEtest06 (void) if (PPPOE_SESSION_GET_VERSION(&pppoesh) != 0x0A) { printf("Error, PPPOE macro pppoe_session_get_version failed: "); - return 0; + FAIL; } if (PPPOE_SESSION_GET_TYPE(&pppoesh) != 0x0B) { printf("Error, PPPOE macro pppoe_session_get_type failed: "); - return 0; + FAIL; } if (PPPOE_DISCOVERY_GET_VERSION(&pppoedh) != 0x0C) { printf("Error, PPPOE macro pppoe_discovery_get_version failed: "); - return 0; + FAIL; } if (PPPOE_DISCOVERY_GET_TYPE(&pppoedh) != 0x0D) { printf("Error, PPPOE macro pppoe_discovery_get_type failed: "); - return 0; + FAIL; } - - return 1; + PASS; } #endif /* UNITTESTS */