From: Victor Julien Date: Tue, 21 Jul 2020 14:04:58 +0000 (+0200) Subject: detect: hide RegisterTests behind ifdef UNITTESTS X-Git-Tag: suricata-6.0.0-beta1~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ab323d32359e1305e585bd301522a663a3fa74b;p=thirdparty%2Fsuricata.git detect: hide RegisterTests behind ifdef UNITTESTS Update all callers to more aggressively use UNITTESTS guards as well. --- diff --git a/src/detect-app-layer-event.c b/src/detect-app-layer-event.c index e6700f063e..686131bf34 100644 --- a/src/detect-app-layer-event.c +++ b/src/detect-app-layer-event.c @@ -51,7 +51,9 @@ static int DetectAppLayerEventPktMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); static int DetectAppLayerEventSetupP1(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectAppLayerEventRegisterTests(void); +#endif static void DetectAppLayerEventFree(DetectEngineCtx *, void *); static int DetectEngineAptEventInspect(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, @@ -72,9 +74,10 @@ void DetectAppLayerEventRegister(void) DetectAppLayerEventPktMatch; sigmatch_table[DETECT_AL_APP_LAYER_EVENT].Setup = DetectAppLayerEventSetupP1; sigmatch_table[DETECT_AL_APP_LAYER_EVENT].Free = DetectAppLayerEventFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_APP_LAYER_EVENT].RegisterTests = DetectAppLayerEventRegisterTests; - +#endif DetectAppLayerInspectEngineRegister("app-layer-events", ALPROTO_UNKNOWN, SIG_FLAG_TOSERVER, 0, DetectEngineAptEventInspect); @@ -806,21 +809,17 @@ static int DetectAppLayerEventTest06(void) DetectAppLayerEventFree(NULL, aled); PASS; } -#endif /* UNITTESTS */ /** * \brief This function registers unit tests for "app-layer-event" keyword. */ -void DetectAppLayerEventRegisterTests(void) +static void DetectAppLayerEventRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectAppLayerEventTest01", DetectAppLayerEventTest01); UtRegisterTest("DetectAppLayerEventTest02", DetectAppLayerEventTest02); UtRegisterTest("DetectAppLayerEventTest03", DetectAppLayerEventTest03); UtRegisterTest("DetectAppLayerEventTest04", DetectAppLayerEventTest04); UtRegisterTest("DetectAppLayerEventTest05", DetectAppLayerEventTest05); UtRegisterTest("DetectAppLayerEventTest06", DetectAppLayerEventTest06); -#endif /* UNITTESTS */ - - return; } +#endif /* UNITTESTS */ diff --git a/src/detect-app-layer-protocol.c b/src/detect-app-layer-protocol.c index 86b7f51b60..569d35253b 100644 --- a/src/detect-app-layer-protocol.c +++ b/src/detect-app-layer-protocol.c @@ -33,7 +33,9 @@ #include "util-unittest.h" #include "util-unittest-helper.h" +#ifdef UNITTESTS static void DetectAppLayerProtocolRegisterTests(void); +#endif static int DetectAppLayerProtocolPacketMatch( DetectEngineThreadCtx *det_ctx, @@ -266,8 +268,10 @@ void DetectAppLayerProtocolRegister(void) DetectAppLayerProtocolSetup; sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].Free = DetectAppLayerProtocolFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].RegisterTests = DetectAppLayerProtocolRegisterTests; +#endif sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].flags = (SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION); @@ -544,11 +548,9 @@ static int DetectAppLayerProtocolTest14(void) PASS; } -#endif /* UNITTESTS */ static void DetectAppLayerProtocolRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectAppLayerProtocolTest01", DetectAppLayerProtocolTest01); UtRegisterTest("DetectAppLayerProtocolTest02", @@ -577,7 +579,5 @@ static void DetectAppLayerProtocolRegisterTests(void) DetectAppLayerProtocolTest13); UtRegisterTest("DetectAppLayerProtocolTest14", DetectAppLayerProtocolTest14); -#endif /* UNITTESTS */ - - return; } +#endif /* UNITTESTS */ diff --git a/src/detect-asn1.c b/src/detect-asn1.c index 37c5e290ff..499f5c81c1 100644 --- a/src/detect-asn1.c +++ b/src/detect-asn1.c @@ -40,7 +40,9 @@ static int DetectAsn1Match(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectAsn1Setup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectAsn1RegisterTests(void); +#endif static void DetectAsn1Free(DetectEngineCtx *, void *); /** @@ -52,9 +54,9 @@ void DetectAsn1Register(void) sigmatch_table[DETECT_ASN1].Match = DetectAsn1Match; sigmatch_table[DETECT_ASN1].Setup = DetectAsn1Setup; sigmatch_table[DETECT_ASN1].Free = DetectAsn1Free; +#ifdef UNITTESTS sigmatch_table[DETECT_ASN1].RegisterTests = DetectAsn1RegisterTests; - - return; +#endif } /** @@ -459,18 +461,14 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectAsn1 */ static void DetectAsn1RegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectAsn1TestReal01", DetectAsn1TestReal01); UtRegisterTest("DetectAsn1TestReal02", DetectAsn1TestReal02); UtRegisterTest("DetectAsn1TestReal03", DetectAsn1TestReal03); UtRegisterTest("DetectAsn1TestReal04", DetectAsn1TestReal04); - -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-base64-data.c b/src/detect-base64-data.c index e12d0d0652..d8df651e92 100644 --- a/src/detect-base64-data.c +++ b/src/detect-base64-data.c @@ -25,7 +25,9 @@ #include "util-unittest.h" static int DetectBase64DataSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectBase64DataRegisterTests(void); +#endif void DetectBase64DataRegister(void) { @@ -35,9 +37,10 @@ void DetectBase64DataRegister(void) sigmatch_table[DETECT_BASE64_DATA].url = "/rules/base64-keywords.html#base64-data"; sigmatch_table[DETECT_BASE64_DATA].Setup = DetectBase64DataSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_BASE64_DATA].RegisterTests = DetectBase64DataRegisterTests; - +#endif sigmatch_table[DETECT_BASE64_DATA].flags |= SIGMATCH_NOOPT; } @@ -247,16 +250,13 @@ end: return retval; } -#endif - static void DetectBase64DataRegisterTests(void) { -#ifdef UNITTESTS g_file_data_buffer_id = DetectBufferTypeGetByName("file_data"); UtRegisterTest("DetectBase64DataSetupTest01", DetectBase64DataSetupTest01); UtRegisterTest("DetectBase64DataSetupTest02", DetectBase64DataSetupTest02); UtRegisterTest("DetectBase64DataSetupTest03", DetectBase64DataSetupTest03); UtRegisterTest("DetectBase64DataSetupTest04", DetectBase64DataSetupTest04); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-base64-decode.c b/src/detect-base64-decode.c index 480b755777..2e047979fd 100644 --- a/src/detect-base64-decode.c +++ b/src/detect-base64-decode.c @@ -34,7 +34,9 @@ static DetectParseRegex decode_pcre; static int DetectBase64DecodeSetup(DetectEngineCtx *, Signature *, const char *); static void DetectBase64DecodeFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectBase64DecodeRegisterTests(void); +#endif void DetectBase64DecodeRegister(void) { @@ -45,9 +47,10 @@ void DetectBase64DecodeRegister(void) "/rules/base64-keywords.html#base64-decode"; sigmatch_table[DETECT_BASE64_DECODE].Setup = DetectBase64DecodeSetup; sigmatch_table[DETECT_BASE64_DECODE].Free = DetectBase64DecodeFree; +#ifdef UNITTESTS sigmatch_table[DETECT_BASE64_DECODE].RegisterTests = DetectBase64DecodeRegisterTests; - +#endif sigmatch_table[DETECT_BASE64_DECODE].flags |= SIGMATCH_OPTIONAL_OPT; DetectSetupParseRegexes(decode_pattern, &decode_pcre); @@ -657,11 +660,8 @@ end: return retval; } -#endif - static void DetectBase64DecodeRegisterTests(void) { -#ifdef UNITTESTS g_http_header_buffer_id = DetectBufferTypeGetByName("http_header"); UtRegisterTest("DetectBase64TestDecodeParse", DetectBase64TestDecodeParse); @@ -676,5 +676,5 @@ static void DetectBase64DecodeRegisterTests(void) DetectBase64DecodeTestDecodeLargeOffset); UtRegisterTest("DetectBase64DecodeTestDecodeRelative", DetectBase64DecodeTestDecodeRelative); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-bypass.c b/src/detect-bypass.c index 5f38517f2c..4ef981d78f 100644 --- a/src/detect-bypass.c +++ b/src/detect-bypass.c @@ -53,7 +53,9 @@ static int DetectBypassMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectBypassSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectBypassRegisterTests(void); +#endif /** * \brief Registration function for keyword: bypass @@ -66,7 +68,9 @@ void DetectBypassRegister(void) sigmatch_table[DETECT_BYPASS].Match = DetectBypassMatch; sigmatch_table[DETECT_BYPASS].Setup = DetectBypassSetup; sigmatch_table[DETECT_BYPASS].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_BYPASS].RegisterTests = DetectBypassRegisterTests; +#endif sigmatch_table[DETECT_BYPASS].flags = SIGMATCH_NOOPT; } @@ -232,11 +236,9 @@ static int DetectBypassTestSig01(void) SCFree(livedev); PASS; } -#endif /* UNITTESTS */ static void DetectBypassRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectBypassTestSig01", DetectBypassTestSig01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-byte-extract.c b/src/detect-byte-extract.c index ed65402321..5ebd7b19c4 100644 --- a/src/detect-byte-extract.c +++ b/src/detect-byte-extract.c @@ -89,7 +89,9 @@ static DetectParseRegex parse_regex; static int DetectByteExtractSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectByteExtractRegisterTests(void); +#endif static void DetectByteExtractFree(DetectEngineCtx *, void *); /** @@ -103,8 +105,9 @@ void DetectByteExtractRegister(void) sigmatch_table[DETECT_BYTE_EXTRACT].Match = NULL; sigmatch_table[DETECT_BYTE_EXTRACT].Setup = DetectByteExtractSetup; sigmatch_table[DETECT_BYTE_EXTRACT].Free = DetectByteExtractFree; +#ifdef UNITTESTS sigmatch_table[DETECT_BYTE_EXTRACT].RegisterTests = DetectByteExtractRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -4728,11 +4731,8 @@ static int DetectByteExtractTestParseNoBase(void) return result; } -#endif /* UNITTESTS */ - static void DetectByteExtractRegisterTests(void) { -#ifdef UNITTESTS g_file_data_buffer_id = DetectBufferTypeGetByName("file_data"); g_http_uri_buffer_id = DetectBufferTypeGetByName("http_uri"); @@ -4810,7 +4810,5 @@ static void DetectByteExtractRegisterTests(void) UtRegisterTest("DetectByteExtractTestParseNoBase", DetectByteExtractTestParseNoBase); -#endif /* UNITTESTS */ - - return; } +#endif /* UNITTESTS */ diff --git a/src/detect-bytejump.c b/src/detect-bytejump.c index bc98223945..c53005fde8 100644 --- a/src/detect-bytejump.c +++ b/src/detect-bytejump.c @@ -65,7 +65,9 @@ static int DetectBytejumpMatch(DetectEngineThreadCtx *det_ctx, static DetectBytejumpData *DetectBytejumpParse(DetectEngineCtx *de_ctx, const char *optstr, char **offset); static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr); static void DetectBytejumpFree(DetectEngineCtx*, void *ptr); +#ifdef UNITTESTS static void DetectBytejumpRegisterTests(void); +#endif void DetectBytejumpRegister (void) { @@ -75,8 +77,9 @@ void DetectBytejumpRegister (void) sigmatch_table[DETECT_BYTEJUMP].Match = DetectBytejumpMatch; sigmatch_table[DETECT_BYTEJUMP].Setup = DetectBytejumpSetup; sigmatch_table[DETECT_BYTEJUMP].Free = DetectBytejumpFree; +#ifdef UNITTESTS sigmatch_table[DETECT_BYTEJUMP].RegisterTests = DetectBytejumpRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -1339,15 +1342,11 @@ static int DetectByteJumpTestPacket08 (void) PASS; } -#endif /* UNITTESTS */ - - /** * \brief this function registers unit tests for DetectBytejump */ static void DetectBytejumpRegisterTests(void) { -#ifdef UNITTESTS g_file_data_buffer_id = DetectBufferTypeGetByName("file_data"); g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data"); @@ -1374,6 +1373,5 @@ static void DetectBytejumpRegisterTests(void) UtRegisterTest("DetectByteJumpTestPacket06", DetectByteJumpTestPacket06); UtRegisterTest("DetectByteJumpTestPacket07", DetectByteJumpTestPacket07); UtRegisterTest("DetectByteJumpTestPacket08", DetectByteJumpTestPacket08); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ diff --git a/src/detect-bytemath.c b/src/detect-bytemath.c index 67a115f3fb..f336a57128 100644 --- a/src/detect-bytemath.c +++ b/src/detect-bytemath.c @@ -113,7 +113,9 @@ static DetectParseRegex parse_regex; static int DetectByteMathSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectByteMathRegisterTests(void); +#endif static void DetectByteMathFree(DetectEngineCtx *, void *); /** @@ -125,8 +127,9 @@ void DetectBytemathRegister(void) sigmatch_table[DETECT_BYTEMATH].Match = NULL; sigmatch_table[DETECT_BYTEMATH].Setup = DetectByteMathSetup; sigmatch_table[DETECT_BYTEMATH].Free = DetectByteMathFree; +#ifdef UNITTESTS sigmatch_table[DETECT_BYTEMATH].RegisterTests = DetectByteMathRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -1171,11 +1174,8 @@ static int DetectByteMathContext01(void) PASS; } -#endif /* UNITTESTS */ - static void DetectByteMathRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectByteMathParseTest01", DetectByteMathParseTest01); UtRegisterTest("DetectByteMathParseTest02", DetectByteMathParseTest02); UtRegisterTest("DetectByteMathParseTest03", DetectByteMathParseTest03); @@ -1193,7 +1193,5 @@ static void DetectByteMathRegisterTests(void) UtRegisterTest("DetectByteMathParseTest15", DetectByteMathParseTest15); UtRegisterTest("DetectByteMathPacket01", DetectByteMathPacket01); UtRegisterTest("DetectByteMathContext01", DetectByteMathContext01); -#endif /* UNITTESTS */ - - return; } +#endif /* UNITTESTS */ diff --git a/src/detect-bytetest.c b/src/detect-bytetest.c index 244108d4f6..eee8242467 100644 --- a/src/detect-bytetest.c +++ b/src/detect-bytetest.c @@ -72,7 +72,9 @@ static int DetectBytetestMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr); static void DetectBytetestFree(DetectEngineCtx *, void *ptr); +#ifdef UNITTESTS static void DetectBytetestRegisterTests(void); +#endif void DetectBytetestRegister (void) { @@ -82,8 +84,9 @@ void DetectBytetestRegister (void) sigmatch_table[DETECT_BYTETEST].Match = DetectBytetestMatch; sigmatch_table[DETECT_BYTETEST].Setup = DetectBytetestSetup; sigmatch_table[DETECT_BYTETEST].Free = DetectBytetestFree; +#ifdef UNITTESTS sigmatch_table[DETECT_BYTETEST].RegisterTests = DetectBytetestRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -1668,15 +1671,11 @@ static int DetectByteTestTestPacket06(void) PASS; } -#endif /* UNITTESTS */ - - /** * \brief this function registers unit tests for DetectBytetest */ static void DetectBytetestRegisterTests(void) { -#ifdef UNITTESTS g_file_data_buffer_id = DetectBufferTypeGetByName("file_data"); g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data"); @@ -1711,6 +1710,5 @@ static void DetectBytetestRegisterTests(void) UtRegisterTest("DetectByteTestTestPacket04", DetectByteTestTestPacket04); UtRegisterTest("DetectByteTestTestPacket05", DetectByteTestTestPacket05); UtRegisterTest("DetectByteTestTestPacket06", DetectByteTestTestPacket06); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ diff --git a/src/detect-cipservice.c b/src/detect-cipservice.c index 765a8a76d2..f6516d3442 100644 --- a/src/detect-cipservice.c +++ b/src/detect-cipservice.c @@ -41,7 +41,9 @@ */ static int DetectCipServiceSetup(DetectEngineCtx *, Signature *, const char *); static void DetectCipServiceFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectCipServiceRegisterTests(void); +#endif static int g_cip_buffer_id = 0; /** @@ -56,9 +58,10 @@ void DetectCipServiceRegister(void) sigmatch_table[DETECT_CIPSERVICE].Match = NULL; sigmatch_table[DETECT_CIPSERVICE].Setup = DetectCipServiceSetup; sigmatch_table[DETECT_CIPSERVICE].Free = DetectCipServiceFree; +#ifdef UNITTESTS sigmatch_table[DETECT_CIPSERVICE].RegisterTests = DetectCipServiceRegisterTests; - +#endif DetectAppLayerInspectEngineRegister("cip", ALPROTO_ENIP, SIG_FLAG_TOSERVER, 0, DetectEngineInspectCIP); @@ -272,20 +275,17 @@ static int DetectCipServiceSignatureTest01 (void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectCipService */ static void DetectCipServiceRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectCipServiceParseTest01", DetectCipServiceParseTest01); UtRegisterTest("DetectCipServiceSignatureTest01", DetectCipServiceSignatureTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ /* * ENIP COMMAND CODE @@ -296,7 +296,9 @@ static void DetectCipServiceRegisterTests(void) */ static int DetectEnipCommandSetup(DetectEngineCtx *, Signature *, const char *); static void DetectEnipCommandFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectEnipCommandRegisterTests(void); +#endif static int g_enip_buffer_id = 0; /** @@ -311,9 +313,10 @@ void DetectEnipCommandRegister(void) sigmatch_table[DETECT_ENIPCOMMAND].Match = NULL; sigmatch_table[DETECT_ENIPCOMMAND].Setup = DetectEnipCommandSetup; sigmatch_table[DETECT_ENIPCOMMAND].Free = DetectEnipCommandFree; +#ifdef UNITTESTS sigmatch_table[DETECT_ENIPCOMMAND].RegisterTests = DetectEnipCommandRegisterTests; - +#endif DetectAppLayerInspectEngineRegister("enip", ALPROTO_ENIP, SIG_FLAG_TOSERVER, 0, DetectEngineInspectENIP); @@ -448,17 +451,14 @@ static int DetectEnipCommandSignatureTest01 (void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectEnipCommand */ static void DetectEnipCommandRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectEnipCommandParseTest01", DetectEnipCommandParseTest01); UtRegisterTest("DetectEnipCommandSignatureTest01", DetectEnipCommandSignatureTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-classtype.c b/src/detect-classtype.c index 24a2c9ad51..dc60a85c95 100644 --- a/src/detect-classtype.c +++ b/src/detect-classtype.c @@ -41,7 +41,9 @@ static DetectParseRegex parse_regex; static int DetectClasstypeSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectClasstypeRegisterTests(void); +#endif /** * \brief Registers the handler functions for the "Classtype" keyword. @@ -52,8 +54,9 @@ void DetectClasstypeRegister(void) sigmatch_table[DETECT_CLASSTYPE].desc = "information about the classification of rules and alerts"; sigmatch_table[DETECT_CLASSTYPE].url = "/rules/meta.html#classtype"; sigmatch_table[DETECT_CLASSTYPE].Setup = DetectClasstypeSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_CLASSTYPE].RegisterTests = DetectClasstypeRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -297,16 +300,13 @@ static int DetectClasstypeTest03(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief This function registers unit tests for Classification Config API. */ static void DetectClasstypeRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectClasstypeTest01", DetectClasstypeTest01); UtRegisterTest("DetectClasstypeTest02", DetectClasstypeTest02); UtRegisterTest("DetectClasstypeTest03", DetectClasstypeTest03); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-config.c b/src/detect-config.c index 37d0d7a1aa..f5bea5b922 100644 --- a/src/detect-config.c +++ b/src/detect-config.c @@ -67,7 +67,9 @@ static int DetectConfigPostMatch (DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); static int DetectConfigSetup (DetectEngineCtx *, Signature *, const char *); static void DetectConfigFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectConfigRegisterTests(void); +#endif /** * \brief Registration function for keyword: filestore @@ -78,8 +80,9 @@ void DetectConfigRegister(void) sigmatch_table[DETECT_CONFIG].Match = DetectConfigPostMatch; sigmatch_table[DETECT_CONFIG].Setup = DetectConfigSetup; sigmatch_table[DETECT_CONFIG].Free = DetectConfigFree; +#ifdef UNITTESTS sigmatch_table[DETECT_CONFIG].RegisterTests = DetectConfigRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -318,11 +321,9 @@ static int DetectConfigTest01(void) DetectEngineCtxFree(de_ctx); PASS; } -#endif /* UNITTESTS */ void DetectConfigRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectConfigTest01", DetectConfigTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-content.c b/src/detect-content.c index bfadd6ddc6..dbd72fc046 100644 --- a/src/detect-content.c +++ b/src/detect-content.c @@ -50,7 +50,9 @@ #include "util-profiling.h" #include "detect-dsize.h" +#ifdef UNITTESTS static void DetectContentRegisterTests(void); +#endif void DetectContentRegister (void) { @@ -60,7 +62,9 @@ void DetectContentRegister (void) sigmatch_table[DETECT_CONTENT].Match = NULL; sigmatch_table[DETECT_CONTENT].Setup = DetectContentSetup; sigmatch_table[DETECT_CONTENT].Free = DetectContentFree; +#ifdef UNITTESTS sigmatch_table[DETECT_CONTENT].RegisterTests = DetectContentRegisterTests; +#endif sigmatch_table[DETECT_CONTENT].flags = (SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION); } @@ -2992,14 +2996,11 @@ static int DetectLongContentTest3(void) return !DetectLongContentTestCommon(sig, 1); } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectContent */ static void DetectContentRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ g_file_data_buffer_id = DetectBufferTypeGetByName("file_data"); g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data"); @@ -3113,5 +3114,5 @@ static void DetectContentRegisterTests(void) UtRegisterTest("DetectLongContentTest1", DetectLongContentTest1); UtRegisterTest("DetectLongContentTest2", DetectLongContentTest2); UtRegisterTest("DetectLongContentTest3", DetectLongContentTest3); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-csum.c b/src/detect-csum.c index 64442e14cf..2dfe0b61f8 100644 --- a/src/detect-csum.c +++ b/src/detect-csum.c @@ -81,7 +81,9 @@ static int DetectICMPV6CsumMatch(DetectEngineThreadCtx *, static int DetectICMPV6CsumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectICMPV6CsumFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectCsumRegisterTests(void); +#endif /** * \brief Registers handlers for all the checksum keywords. The checksum @@ -131,45 +133,39 @@ void DetectCsumRegister (void) sigmatch_table[DETECT_IPV4_CSUM].Match = DetectIPV4CsumMatch; sigmatch_table[DETECT_IPV4_CSUM].Setup = DetectIPV4CsumSetup; sigmatch_table[DETECT_IPV4_CSUM].Free = DetectIPV4CsumFree; +#ifdef UNITTESTS sigmatch_table[DETECT_IPV4_CSUM].RegisterTests = DetectCsumRegisterTests; +#endif sigmatch_table[DETECT_TCPV4_CSUM].name = "tcpv4-csum"; sigmatch_table[DETECT_TCPV4_CSUM].Match = DetectTCPV4CsumMatch; sigmatch_table[DETECT_TCPV4_CSUM].Setup = DetectTCPV4CsumSetup; sigmatch_table[DETECT_TCPV4_CSUM].Free = DetectTCPV4CsumFree; - sigmatch_table[DETECT_TCPV4_CSUM].RegisterTests = NULL; sigmatch_table[DETECT_TCPV6_CSUM].name = "tcpv6-csum"; sigmatch_table[DETECT_TCPV6_CSUM].Match = DetectTCPV6CsumMatch; sigmatch_table[DETECT_TCPV6_CSUM].Setup = DetectTCPV6CsumSetup; sigmatch_table[DETECT_TCPV6_CSUM].Free = DetectTCPV6CsumFree; - sigmatch_table[DETECT_TCPV6_CSUM].RegisterTests = NULL; sigmatch_table[DETECT_UDPV4_CSUM].name = "udpv4-csum"; sigmatch_table[DETECT_UDPV4_CSUM].Match = DetectUDPV4CsumMatch; sigmatch_table[DETECT_UDPV4_CSUM].Setup = DetectUDPV4CsumSetup; sigmatch_table[DETECT_UDPV4_CSUM].Free = DetectUDPV4CsumFree; - sigmatch_table[DETECT_UDPV4_CSUM].RegisterTests = NULL; sigmatch_table[DETECT_UDPV6_CSUM].name = "udpv6-csum"; sigmatch_table[DETECT_UDPV6_CSUM].Match = DetectUDPV6CsumMatch; sigmatch_table[DETECT_UDPV6_CSUM].Setup = DetectUDPV6CsumSetup; sigmatch_table[DETECT_UDPV6_CSUM].Free = DetectUDPV6CsumFree; - sigmatch_table[DETECT_UDPV6_CSUM].RegisterTests = NULL; sigmatch_table[DETECT_ICMPV4_CSUM].name = "icmpv4-csum"; sigmatch_table[DETECT_ICMPV4_CSUM].Match = DetectICMPV4CsumMatch; sigmatch_table[DETECT_ICMPV4_CSUM].Setup = DetectICMPV4CsumSetup; sigmatch_table[DETECT_ICMPV4_CSUM].Free = DetectICMPV4CsumFree; - sigmatch_table[DETECT_ICMPV4_CSUM].RegisterTests = NULL; sigmatch_table[DETECT_ICMPV6_CSUM].name = "icmpv6-csum"; sigmatch_table[DETECT_ICMPV6_CSUM].Match = DetectICMPV6CsumMatch; sigmatch_table[DETECT_ICMPV6_CSUM].Setup = DetectICMPV6CsumSetup; sigmatch_table[DETECT_ICMPV6_CSUM].Free = DetectICMPV6CsumFree; - sigmatch_table[DETECT_ICMPV6_CSUM].RegisterTests = NULL; - - return; } /** @@ -1056,12 +1052,8 @@ static int DetectCsumICMPV6Test01(void) PASS; } -#endif /* UNITTESTS */ - static void DetectCsumRegisterTests(void) { -#ifdef UNITTESTS - UtRegisterTest("DetectCsumValidArgsTestParse01", DetectCsumValidArgsTestParse01); UtRegisterTest("DetectCsumInvalidArgsTestParse02", @@ -1071,6 +1063,5 @@ static void DetectCsumRegisterTests(void) UtRegisterTest("DetectCsumICMPV6Test01", DetectCsumICMPV6Test01); - -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-dce-iface.c b/src/detect-dce-iface.c index 589ca37d54..e3236dfada 100644 --- a/src/detect-dce-iface.c +++ b/src/detect-dce-iface.c @@ -58,7 +58,9 @@ static int DetectDceIfaceMatchRust(DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchCtx *m); static int DetectDceIfaceSetup(DetectEngineCtx *, Signature *, const char *); static void DetectDceIfaceFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectDceIfaceRegisterTests(void); +#endif static int g_dce_generic_list_id = 0; static int InspectDceGeneric(ThreadVars *tv, @@ -77,8 +79,9 @@ void DetectDceIfaceRegister(void) sigmatch_table[DETECT_DCE_IFACE].AppLayerTxMatch = DetectDceIfaceMatchRust; sigmatch_table[DETECT_DCE_IFACE].Setup = DetectDceIfaceSetup; sigmatch_table[DETECT_DCE_IFACE].Free = DetectDceIfaceFree; +#ifdef UNITTESTS sigmatch_table[DETECT_DCE_IFACE].RegisterTests = DetectDceIfaceRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); g_dce_generic_list_id = DetectBufferTypeRegister("dce_generic"); @@ -823,11 +826,8 @@ static int DetectDceIfaceTestParse2(void) return result; } -#endif - static void DetectDceIfaceRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDceIfaceTestParse1", DetectDceIfaceTestParse1); /* Disabled because of bug_753. Would be enabled, once we rewrite * dce parser */ @@ -835,5 +835,5 @@ static void DetectDceIfaceRegisterTests(void) UtRegisterTest("DetectDceIfaceTestParse13", DetectDceIfaceTestParse13, 1); #endif UtRegisterTest("DetectDceIfaceTestParse2", DetectDceIfaceTestParse2); -#endif } +#endif /* UNITTESTS */ diff --git a/src/detect-dce-opnum.c b/src/detect-dce-opnum.c index fc64e31670..6344e3aea5 100644 --- a/src/detect-dce-opnum.c +++ b/src/detect-dce-opnum.c @@ -59,7 +59,9 @@ static int DetectDceOpnumMatchRust(DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchCtx *m); static int DetectDceOpnumSetup(DetectEngineCtx *, Signature *, const char *); static void DetectDceOpnumFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectDceOpnumRegisterTests(void); +#endif static int g_dce_generic_list_id = 0; /** @@ -72,8 +74,9 @@ void DetectDceOpnumRegister(void) sigmatch_table[DETECT_DCE_OPNUM].AppLayerTxMatch = DetectDceOpnumMatchRust; sigmatch_table[DETECT_DCE_OPNUM].Setup = DetectDceOpnumSetup; sigmatch_table[DETECT_DCE_OPNUM].Free = DetectDceOpnumFree; +#ifdef UNITTESTS sigmatch_table[DETECT_DCE_OPNUM].RegisterTests = DetectDceOpnumRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); g_dce_generic_list_id = DetectBufferTypeRegister("dce_generic"); @@ -2402,11 +2405,9 @@ static int DetectDceOpnumTestParse13(void) return result; } #endif -#endif /* UNITTESTS */ static void DetectDceOpnumRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDceOpnumTestParse01", DetectDceOpnumTestParse01); UtRegisterTest("DetectDceOpnumTestParse02", DetectDceOpnumTestParse02); /* Disabled because of bug_753. Would be enabled, once we rewrite @@ -2417,5 +2418,5 @@ static void DetectDceOpnumRegisterTests(void) UtRegisterTest("DetectDceOpnumTestParse12", DetectDceOpnumTestParse12, 1); UtRegisterTest("DetectDceOpnumTestParse13", DetectDceOpnumTestParse13, 1); #endif -#endif } +#endif /* UNITTESTS */ diff --git a/src/detect-dce-stub-data.c b/src/detect-dce-stub-data.c index 3c7e146fb8..ace1346d84 100644 --- a/src/detect-dce-stub-data.c +++ b/src/detect-dce-stub-data.c @@ -60,7 +60,9 @@ #define KEYWORD_NAME "dce_stub_data" static int DetectDceStubDataSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectDceStubDataRegisterTests(void); +#endif static int g_dce_stub_data_buffer_id = 0; static InspectionBuffer *GetSMBData(DetectEngineThreadCtx *det_ctx, @@ -117,7 +119,9 @@ void DetectDceStubDataRegister(void) sigmatch_table[DETECT_DCE_STUB_DATA].name = "dcerpc.stub_data"; sigmatch_table[DETECT_DCE_STUB_DATA].alias = "dce_stub_data"; sigmatch_table[DETECT_DCE_STUB_DATA].Setup = DetectDceStubDataSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_DCE_STUB_DATA].RegisterTests = DetectDceStubDataRegisterTests; +#endif sigmatch_table[DETECT_DCE_STUB_DATA].flags |= SIGMATCH_NOOPT|SIGMATCH_INFO_STICKY_BUFFER; DetectAppLayerInspectEngineRegister2(BUFFER_NAME, @@ -1893,12 +1897,8 @@ static int DetectDceStubDataTestParse05(void) return result; } - -#endif - static void DetectDceStubDataRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDceStubDataTestParse01", DetectDceStubDataTestParse01); UtRegisterTest("DetectDceStubDataTestParse02", @@ -1909,7 +1909,5 @@ static void DetectDceStubDataRegisterTests(void) DetectDceStubDataTestParse04); UtRegisterTest("DetectDceStubDataTestParse05", DetectDceStubDataTestParse05); -#endif - - return; } +#endif diff --git a/src/detect-depth.c b/src/detect-depth.c index 106d96c515..1e82aa1c82 100644 --- a/src/detect-depth.c +++ b/src/detect-depth.c @@ -53,7 +53,6 @@ void DetectDepthRegister (void) sigmatch_table[DETECT_DEPTH].Match = NULL; sigmatch_table[DETECT_DEPTH].Setup = DetectDepthSetup; sigmatch_table[DETECT_DEPTH].Free = NULL; - sigmatch_table[DETECT_DEPTH].RegisterTests = NULL; sigmatch_table[DETECT_STARTS_WITH].name = "startswith"; sigmatch_table[DETECT_STARTS_WITH].desc = "pattern must be at the start of a buffer (same as 'depth:')"; diff --git a/src/detect-detection-filter.c b/src/detect-detection-filter.c index 85c6439f6f..b4f57d1c4a 100644 --- a/src/detect-detection-filter.c +++ b/src/detect-detection-filter.c @@ -53,7 +53,9 @@ static DetectParseRegex parse_regex; static int DetectDetectionFilterMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectDetectionFilterSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectDetectionFilterRegisterTests(void); +#endif static void DetectDetectionFilterFree(DetectEngineCtx *, void *); /** @@ -67,7 +69,9 @@ void DetectDetectionFilterRegister (void) sigmatch_table[DETECT_DETECTION_FILTER].Match = DetectDetectionFilterMatch; sigmatch_table[DETECT_DETECTION_FILTER].Setup = DetectDetectionFilterSetup; sigmatch_table[DETECT_DETECTION_FILTER].Free = DetectDetectionFilterFree; +#ifdef UNITTESTS sigmatch_table[DETECT_DETECTION_FILTER].RegisterTests = DetectDetectionFilterRegisterTests; +#endif /* this is compatible to ip-only signatures */ sigmatch_table[DETECT_DETECTION_FILTER].flags |= SIGMATCH_IPONLY_COMPAT; @@ -625,11 +629,9 @@ end: HostShutdown(); return result; } -#endif /* UNITTESTS */ static void DetectDetectionFilterRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDetectionFilterTestParse01", DetectDetectionFilterTestParse01); UtRegisterTest("DetectDetectionFilterTestParse02", @@ -648,6 +650,5 @@ static void DetectDetectionFilterRegisterTests(void) DetectDetectionFilterTestSig2); UtRegisterTest("DetectDetectionFilterTestSig3", DetectDetectionFilterTestSig3); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ diff --git a/src/detect-distance.c b/src/detect-distance.c index 456ec7ee4d..11ea8ec30d 100644 --- a/src/detect-distance.c +++ b/src/detect-distance.c @@ -49,7 +49,9 @@ #include "util-unittest-helper.h" static int DetectDistanceSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectDistanceRegisterTests(void); +#endif void DetectDistanceRegister(void) { @@ -59,7 +61,9 @@ void DetectDistanceRegister(void) sigmatch_table[DETECT_DISTANCE].Match = NULL; sigmatch_table[DETECT_DISTANCE].Setup = DetectDistanceSetup; sigmatch_table[DETECT_DISTANCE].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_DISTANCE].RegisterTests = DetectDistanceRegisterTests; +#endif } static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s, @@ -234,14 +238,11 @@ static int DetectDistanceTestPacket01 (void) end: return result; } -#endif /* UNITTESTS */ static void DetectDistanceRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDistanceTest01 -- distance / within mix", DetectDistanceTest01); UtRegisterTest("DetectDistanceTestPacket01", DetectDistanceTestPacket01); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ diff --git a/src/detect-dnp3.c b/src/detect-dnp3.c index 4ec6b54884..ea1cb1c7f5 100644 --- a/src/detect-dnp3.c +++ b/src/detect-dnp3.c @@ -121,10 +121,12 @@ DNP3Mapping DNP3FunctionNameMap[] = { {"authenticate_resp", 131} }; +#ifdef UNITTESTS static void DetectDNP3FuncRegisterTests(void); static void DetectDNP3IndRegisterTests(void); static void DetectDNP3ObjRegisterTests(void); static void DetectDNP3DataRegisterTests(void); +#endif /** * \brief Utility function to trim leading and trailing whitespace @@ -498,9 +500,10 @@ static void DetectDNP3FuncRegister(void) sigmatch_table[DETECT_AL_DNP3FUNC].AppLayerTxMatch = DetectDNP3FuncMatch; sigmatch_table[DETECT_AL_DNP3FUNC].Setup = DetectDNP3FuncSetup; sigmatch_table[DETECT_AL_DNP3FUNC].Free = DetectDNP3Free; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_DNP3FUNC].RegisterTests = DetectDNP3FuncRegisterTests; - +#endif SCReturn; } @@ -516,9 +519,10 @@ static void DetectDNP3IndRegister(void) sigmatch_table[DETECT_AL_DNP3IND].AppLayerTxMatch = DetectDNP3IndMatch; sigmatch_table[DETECT_AL_DNP3IND].Setup = DetectDNP3IndSetup; sigmatch_table[DETECT_AL_DNP3IND].Free = DetectDNP3Free; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_DNP3IND].RegisterTests = DetectDNP3IndRegisterTests; - +#endif SCReturn; } @@ -534,9 +538,10 @@ static void DetectDNP3ObjRegister(void) sigmatch_table[DETECT_AL_DNP3OBJ].AppLayerTxMatch = DetectDNP3ObjMatch; sigmatch_table[DETECT_AL_DNP3OBJ].Setup = DetectDNP3ObjSetup; sigmatch_table[DETECT_AL_DNP3OBJ].Free = DetectDNP3Free; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_DNP3OBJ].RegisterTests = DetectDNP3ObjRegisterTests; - +#endif SCReturn; } @@ -561,9 +566,10 @@ static void DetectDNP3DataRegister(void) sigmatch_table[DETECT_AL_DNP3DATA].desc = "make the following content options to match on the re-assembled application buffer"; sigmatch_table[DETECT_AL_DNP3DATA].url = "/rules/dnp3-keywords.html#dnp3-data"; sigmatch_table[DETECT_AL_DNP3DATA].Setup = DetectDNP3DataSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_DNP3DATA].RegisterTests = DetectDNP3DataRegisterTests; - +#endif sigmatch_table[DETECT_AL_DNP3DATA].flags |= SIGMATCH_NOOPT|SIGMATCH_INFO_STICKY_BUFFER; DetectAppLayerInspectEngineRegister2("dnp3_data", @@ -1029,39 +1035,30 @@ static int DetectDNP3DataTest02(void) PASS; } -#endif - static void DetectDNP3FuncRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDNP3FuncParseFunctionCodeTest", DetectDNP3FuncParseFunctionCodeTest); UtRegisterTest("DetectDNP3FuncTest01", DetectDNP3FuncTest01); -#endif } static void DetectDNP3IndRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDNP3IndTestParseAsInteger", DetectDNP3IndTestParseAsInteger); UtRegisterTest("DetectDNP3IndTestParseByName", DetectDNP3IndTestParseByName); -#endif } static void DetectDNP3ObjRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDNP3ObjParseTest", DetectDNP3ObjParseTest); UtRegisterTest("DetectDNP3ObjSetupTest", DetectDNP3ObjSetupTest); -#endif } void DetectDNP3DataRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDNP3DataTest01", DetectDNP3DataTest01); UtRegisterTest("DetectDNP3DataTest02", DetectDNP3DataTest02); -#endif } +#endif diff --git a/src/detect-dns-query.c b/src/detect-dns-query.c index 86291ac4fc..cdd39c44d8 100644 --- a/src/detect-dns-query.c +++ b/src/detect-dns-query.c @@ -62,7 +62,9 @@ #include "rust.h" static int DetectDnsQuerySetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectDnsQueryRegisterTests(void); +#endif static int g_dns_query_buffer_id = 0; struct DnsQueryGetDataArgs { @@ -210,7 +212,9 @@ void DetectDnsQueryRegister (void) sigmatch_table[DETECT_AL_DNS_QUERY].desc = "sticky buffer to match DNS query-buffer"; sigmatch_table[DETECT_AL_DNS_QUERY].url = "/rules/dns-keywords.html#dns-query"; sigmatch_table[DETECT_AL_DNS_QUERY].Setup = DetectDnsQuerySetup; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_DNS_QUERY].RegisterTests = DetectDnsQueryRegisterTests; +#endif sigmatch_table[DETECT_AL_DNS_QUERY].flags |= SIGMATCH_NOOPT; sigmatch_table[DETECT_AL_DNS_QUERY].flags |= SIGMATCH_INFO_STICKY_BUFFER; @@ -1248,11 +1252,8 @@ static int DetectDnsQueryIsdataatParseTest(void) PASS; } -#endif - static void DetectDnsQueryRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectDnsQueryTest01", DetectDnsQueryTest01); UtRegisterTest("DetectDnsQueryTest02", DetectDnsQueryTest02); UtRegisterTest("DetectDnsQueryTest03 -- tcp", DetectDnsQueryTest03); @@ -1266,5 +1267,5 @@ static void DetectDnsQueryRegisterTests(void) UtRegisterTest("DetectDnsQueryIsdataatParseTest", DetectDnsQueryIsdataatParseTest); -#endif } +#endif diff --git a/src/detect-dsize.c b/src/detect-dsize.c index 69f0577bbc..164bd05602 100644 --- a/src/detect-dsize.c +++ b/src/detect-dsize.c @@ -52,7 +52,9 @@ static DetectParseRegex parse_regex; static int DetectDsizeMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectDsizeSetup (DetectEngineCtx *, Signature *s, const char *str); +#ifdef UNITTESTS static void DsizeRegisterTests(void); +#endif static void DetectDsizeFree(DetectEngineCtx *, void *); static int PrefilterSetupDsize(DetectEngineCtx *de_ctx, SigGroupHead *sgh); @@ -69,8 +71,9 @@ void DetectDsizeRegister (void) sigmatch_table[DETECT_DSIZE].Match = DetectDsizeMatch; sigmatch_table[DETECT_DSIZE].Setup = DetectDsizeSetup; sigmatch_table[DETECT_DSIZE].Free = DetectDsizeFree; +#ifdef UNITTESTS sigmatch_table[DETECT_DSIZE].RegisterTests = DsizeRegisterTests; - +#endif sigmatch_table[DETECT_DSIZE].SupportsPrefilter = PrefilterDsizeIsPrefilterable; sigmatch_table[DETECT_DSIZE].SetupPrefilter = PrefilterSetupDsize; @@ -954,14 +957,12 @@ end: return result; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for dsize */ static void DsizeRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DsizeTestParse01", DsizeTestParse01); UtRegisterTest("DsizeTestParse02", DsizeTestParse02); UtRegisterTest("DsizeTestParse03", DsizeTestParse03); @@ -984,6 +985,5 @@ static void DsizeRegisterTests(void) UtRegisterTest("DsizeTestParse20", DsizeTestParse20); UtRegisterTest("DetectDsizeIcmpv6Test01", DetectDsizeIcmpv6Test01); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ diff --git a/src/detect-engine-event.c b/src/detect-engine-event.c index f746a960b2..f81186e825 100644 --- a/src/detect-engine-event.c +++ b/src/detect-engine-event.c @@ -52,8 +52,9 @@ static int DetectEngineEventSetup (DetectEngineCtx *, Signature *, const char *) static int DetectDecodeEventSetup (DetectEngineCtx *, Signature *, const char *); static int DetectStreamEventSetup (DetectEngineCtx *, Signature *, const char *); static void DetectEngineEventFree (DetectEngineCtx *, void *); +#ifdef UNITTESTS void EngineEventRegisterTests(void); - +#endif /** * \brief Registration function for decode-event: keyword @@ -64,7 +65,9 @@ void DetectEngineEventRegister (void) sigmatch_table[DETECT_ENGINE_EVENT].Match = DetectEngineEventMatch; sigmatch_table[DETECT_ENGINE_EVENT].Setup = DetectEngineEventSetup; sigmatch_table[DETECT_ENGINE_EVENT].Free = DetectEngineEventFree; +#ifdef UNITTESTS sigmatch_table[DETECT_ENGINE_EVENT].RegisterTests = EngineEventRegisterTests; +#endif sigmatch_table[DETECT_DECODE_EVENT].name = "decode-event"; sigmatch_table[DETECT_DECODE_EVENT].Match = DetectEngineEventMatch; @@ -378,19 +381,17 @@ error: SCFree(p); return 0; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for EngineEvent */ void EngineEventRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("EngineEventTestParse01", EngineEventTestParse01); UtRegisterTest("EngineEventTestParse02", EngineEventTestParse02); UtRegisterTest("EngineEventTestParse03", EngineEventTestParse03); UtRegisterTest("EngineEventTestParse04", EngineEventTestParse04); UtRegisterTest("EngineEventTestParse05", EngineEventTestParse05); UtRegisterTest("EngineEventTestParse06", EngineEventTestParse06); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-engine-register.c b/src/detect-engine-register.c index 1a81f0c52e..3773b3534d 100644 --- a/src/detect-engine-register.c +++ b/src/detect-engine-register.c @@ -602,11 +602,11 @@ void SigTableSetup(void) DetectBufferTypeCloseRegistration(); } +#ifdef UNITTESTS void SigTableRegisterTests(void) { /* register the tests */ - int i = 0; - for (i = 0; i < DETECT_TBLSIZE; i++) { + for (int i = 0; i < DETECT_TBLSIZE; i++) { g_ut_modules++; if (sigmatch_table[i].RegisterTests != NULL) { sigmatch_table[i].RegisterTests(); @@ -621,3 +621,4 @@ void SigTableRegisterTests(void) } } } +#endif diff --git a/src/detect-fast-pattern.c b/src/detect-fast-pattern.c index b7c60078bc..0a3d0d1fc1 100644 --- a/src/detect-fast-pattern.c +++ b/src/detect-fast-pattern.c @@ -43,7 +43,9 @@ static DetectParseRegex parse_regex; static int DetectFastPatternSetup(DetectEngineCtx *, Signature *, const char *); -void DetectFastPatternRegisterTests(void); +#ifdef UNITTESTS +static void DetectFastPatternRegisterTests(void); +#endif /* holds the list of sm match lists that need to be searched for a keyword * that has fp support */ @@ -170,8 +172,9 @@ void DetectFastPatternRegister(void) sigmatch_table[DETECT_FAST_PATTERN].Match = NULL; sigmatch_table[DETECT_FAST_PATTERN].Setup = DetectFastPatternSetup; sigmatch_table[DETECT_FAST_PATTERN].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_FAST_PATTERN].RegisterTests = DetectFastPatternRegisterTests; - +#endif sigmatch_table[DETECT_FAST_PATTERN].flags |= SIGMATCH_NOOPT; DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); @@ -18864,11 +18867,8 @@ static int DetectFastPatternTest671(void) PASS; } -#endif - -void DetectFastPatternRegisterTests(void) +static void DetectFastPatternRegisterTests(void) { -#ifdef UNITTESTS g_file_data_buffer_id = DetectBufferTypeGetByName("file_data"); g_http_method_buffer_id = DetectBufferTypeGetByName("http_method"); g_http_uri_buffer_id = DetectBufferTypeGetByName("http_uri"); @@ -19584,7 +19584,5 @@ void DetectFastPatternRegisterTests(void) * - if 2 duplicate patterns, with no chop set get unique ids. */ UtRegisterTest("DetectFastPatternTest671", DetectFastPatternTest671); -#endif - - return; } +#endif diff --git a/src/detect-fileext.c b/src/detect-fileext.c index ae116ec47b..2856bfda4c 100644 --- a/src/detect-fileext.c +++ b/src/detect-fileext.c @@ -54,7 +54,9 @@ static int DetectFileextMatch (DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); static int DetectFileextSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectFileextRegisterTests(void); +#endif static void DetectFileextFree(DetectEngineCtx *, void *); static int g_file_match_list_id = 0; @@ -69,7 +71,9 @@ void DetectFileextRegister(void) sigmatch_table[DETECT_FILEEXT].FileMatch = DetectFileextMatch; sigmatch_table[DETECT_FILEEXT].Setup = DetectFileextSetup; sigmatch_table[DETECT_FILEEXT].Free = DetectFileextFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FILEEXT].RegisterTests = DetectFileextRegisterTests; +#endif sigmatch_table[DETECT_FILEEXT].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION; sigmatch_table[DETECT_FILEEXT].alternative = DETECT_FILE_NAME; @@ -293,16 +297,13 @@ static int DetectFileextTestParse03 (void) return 0; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectFileext */ void DetectFileextRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectFileextTestParse01", DetectFileextTestParse01); UtRegisterTest("DetectFileextTestParse02", DetectFileextTestParse02); UtRegisterTest("DetectFileextTestParse03", DetectFileextTestParse03); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-filemagic.c b/src/detect-filemagic.c index 51ab4ba9e6..6d53c4705a 100644 --- a/src/detect-filemagic.c +++ b/src/detect-filemagic.c @@ -81,7 +81,9 @@ void DetectFilemagicRegister(void) static int DetectFilemagicMatch (DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); static int DetectFilemagicSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectFilemagicRegisterTests(void); +#endif static void DetectFilemagicFree(DetectEngineCtx *, void *); static int g_file_match_list_id = 0; @@ -110,7 +112,9 @@ void DetectFilemagicRegister(void) sigmatch_table[DETECT_FILEMAGIC].FileMatch = DetectFilemagicMatch; sigmatch_table[DETECT_FILEMAGIC].Setup = DetectFilemagicSetup; sigmatch_table[DETECT_FILEMAGIC].Free = DetectFilemagicFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FILEMAGIC].RegisterTests = DetectFilemagicRegisterTests; +#endif sigmatch_table[DETECT_FILEMAGIC].flags = SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION; sigmatch_table[DETECT_FILEMAGIC].alternative = DETECT_FILE_MAGIC; @@ -632,19 +636,15 @@ static int DetectFilemagicTestParse03 (void) return 0; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectFilemagic */ void DetectFilemagicRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectFilemagicTestParse01", DetectFilemagicTestParse01); UtRegisterTest("DetectFilemagicTestParse02", DetectFilemagicTestParse02); UtRegisterTest("DetectFilemagicTestParse03", DetectFilemagicTestParse03); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ #endif /* HAVE_MAGIC */ diff --git a/src/detect-filemd5.c b/src/detect-filemd5.c index cd629698a1..5ca10ee159 100644 --- a/src/detect-filemd5.c +++ b/src/detect-filemd5.c @@ -45,10 +45,7 @@ static int DetectFileMd5SetupNoSupport (DetectEngineCtx *a, Signature *b, const void DetectFileMd5Register(void) { sigmatch_table[DETECT_FILEMD5].name = "filemd5"; - sigmatch_table[DETECT_FILEMD5].FileMatch = NULL; sigmatch_table[DETECT_FILEMD5].Setup = DetectFileMd5SetupNoSupport; - sigmatch_table[DETECT_FILEMD5].Free = NULL; - sigmatch_table[DETECT_FILEMD5].RegisterTests = NULL; sigmatch_table[DETECT_FILEMD5].flags = SIGMATCH_NOT_BUILT; SCLogDebug("registering filemd5 rule option"); @@ -60,7 +57,9 @@ void DetectFileMd5Register(void) static int g_file_match_list_id = 0; static int DetectFileMd5Setup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectFileMd5RegisterTests(void); +#endif /** * \brief Registration function for keyword: filemd5 @@ -73,8 +72,9 @@ void DetectFileMd5Register(void) sigmatch_table[DETECT_FILEMD5].FileMatch = DetectFileHashMatch; sigmatch_table[DETECT_FILEMD5].Setup = DetectFileMd5Setup; sigmatch_table[DETECT_FILEMD5].Free = DetectFileHashFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FILEMD5].RegisterTests = DetectFileMd5RegisterTests; - +#endif g_file_match_list_id = DetectBufferTypeRegister("files"); SCLogDebug("registering filemd5 rule option"); @@ -153,14 +153,12 @@ static int MD5MatchTest01(void) ROHashFree(hash); return 1; } -#endif void DetectFileMd5RegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("MD5MatchTest01", MD5MatchTest01); -#endif } +#endif #endif /* HAVE_NSS */ diff --git a/src/detect-filename.c b/src/detect-filename.c index fd2d9a1f73..7e6fd36d4d 100644 --- a/src/detect-filename.c +++ b/src/detect-filename.c @@ -58,7 +58,9 @@ static int DetectFilenameMatch (DetectEngineThreadCtx *, Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *); static int DetectFilenameSetup (DetectEngineCtx *, Signature *, const char *); static int DetectFilenameSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str); +#ifdef UNITTESTS static void DetectFilenameRegisterTests(void); +#endif static void DetectFilenameFree(DetectEngineCtx *, void *); static int g_file_match_list_id = 0; static int g_file_name_buffer_id = 0; @@ -83,7 +85,9 @@ void DetectFilenameRegister(void) sigmatch_table[DETECT_FILENAME].FileMatch = DetectFilenameMatch; sigmatch_table[DETECT_FILENAME].Setup = DetectFilenameSetup; sigmatch_table[DETECT_FILENAME].Free = DetectFilenameFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FILENAME].RegisterTests = DetectFilenameRegisterTests; +#endif sigmatch_table[DETECT_FILENAME].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION; sigmatch_table[DETECT_FILENAME].alternative = DETECT_FILE_NAME; @@ -555,18 +559,16 @@ static int DetectFilenameTestParse03 (void) return 0; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for DetectFilename */ void DetectFilenameRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectFilenameSignatureParseTest01", DetectFilenameSignatureParseTest01); UtRegisterTest("DetectFilenameTestParse01", DetectFilenameTestParse01); UtRegisterTest("DetectFilenameTestParse02", DetectFilenameTestParse02); UtRegisterTest("DetectFilenameTestParse03", DetectFilenameTestParse03); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-filesha1.c b/src/detect-filesha1.c index beac4209e6..7de79d3e29 100644 --- a/src/detect-filesha1.c +++ b/src/detect-filesha1.c @@ -46,10 +46,7 @@ static int DetectFileSha1SetupNoSupport (DetectEngineCtx *a, Signature *b, const void DetectFileSha1Register(void) { sigmatch_table[DETECT_FILESHA1].name = "filesha1"; - sigmatch_table[DETECT_FILESHA1].FileMatch = NULL; sigmatch_table[DETECT_FILESHA1].Setup = DetectFileSha1SetupNoSupport; - sigmatch_table[DETECT_FILESHA1].Free = NULL; - sigmatch_table[DETECT_FILESHA1].RegisterTests = NULL; sigmatch_table[DETECT_FILESHA1].flags = SIGMATCH_NOT_BUILT; SCLogDebug("registering filesha1 rule option"); @@ -59,7 +56,9 @@ void DetectFileSha1Register(void) #else /* HAVE_NSS */ static int DetectFileSha1Setup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectFileSha1RegisterTests(void); +#endif static int g_file_match_list_id = 0; /** @@ -73,8 +72,9 @@ void DetectFileSha1Register(void) sigmatch_table[DETECT_FILESHA1].FileMatch = DetectFileHashMatch; sigmatch_table[DETECT_FILESHA1].Setup = DetectFileSha1Setup; sigmatch_table[DETECT_FILESHA1].Free = DetectFileHashFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FILESHA1].RegisterTests = DetectFileSha1RegisterTests; - +#endif g_file_match_list_id = DetectBufferTypeRegister("files"); SCLogDebug("registering filesha1 rule option"); @@ -153,13 +153,10 @@ static int SHA1MatchTest01(void) ROHashFree(hash); return 1; } -#endif -void DetectFileSha1RegisterTests(void) +static void DetectFileSha1RegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("SHA1MatchTest01", SHA1MatchTest01); -#endif } - +#endif #endif /* HAVE_NSS */ diff --git a/src/detect-filesha256.c b/src/detect-filesha256.c index 1157b8d9ab..d76e97442c 100644 --- a/src/detect-filesha256.c +++ b/src/detect-filesha256.c @@ -46,10 +46,7 @@ static int DetectFileSha256SetupNoSupport (DetectEngineCtx *a, Signature *b, con void DetectFileSha256Register(void) { sigmatch_table[DETECT_FILESHA256].name = "filesha256"; - sigmatch_table[DETECT_FILESHA256].FileMatch = NULL; sigmatch_table[DETECT_FILESHA256].Setup = DetectFileSha256SetupNoSupport; - sigmatch_table[DETECT_FILESHA256].Free = NULL; - sigmatch_table[DETECT_FILESHA256].RegisterTests = NULL; sigmatch_table[DETECT_FILESHA256].flags = SIGMATCH_NOT_BUILT; SCLogDebug("registering filesha256 rule option"); @@ -59,7 +56,9 @@ void DetectFileSha256Register(void) #else /* HAVE_NSS */ static int DetectFileSha256Setup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectFileSha256RegisterTests(void); +#endif static int g_file_match_list_id = 0; /** @@ -73,7 +72,9 @@ void DetectFileSha256Register(void) sigmatch_table[DETECT_FILESHA256].FileMatch = DetectFileHashMatch; sigmatch_table[DETECT_FILESHA256].Setup = DetectFileSha256Setup; sigmatch_table[DETECT_FILESHA256].Free = DetectFileHashFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FILESHA256].RegisterTests = DetectFileSha256RegisterTests; +#endif g_file_match_list_id = DetectBufferTypeRegister("files"); @@ -153,13 +154,10 @@ static int SHA256MatchTest01(void) ROHashFree(hash); return 1; } -#endif void DetectFileSha256RegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("SHA256MatchTest01", SHA256MatchTest01); -#endif } - +#endif #endif /* HAVE_NSS */ diff --git a/src/detect-filesize.c b/src/detect-filesize.c index 50a9145d46..999c6b5cfb 100644 --- a/src/detect-filesize.c +++ b/src/detect-filesize.c @@ -53,7 +53,9 @@ static int DetectFilesizeMatch (DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m); static int DetectFilesizeSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFilesizeFree (DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectFilesizeRegisterTests (void); +#endif static int g_file_match_list_id = 0; /** @@ -68,8 +70,9 @@ void DetectFilesizeRegister(void) sigmatch_table[DETECT_FILESIZE].FileMatch = DetectFilesizeMatch; sigmatch_table[DETECT_FILESIZE].Setup = DetectFilesizeSetup; sigmatch_table[DETECT_FILESIZE].Free = DetectFilesizeFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FILESIZE].RegisterTests = DetectFilesizeRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); g_file_match_list_id = DetectBufferTypeRegister("files"); @@ -481,19 +484,16 @@ end: return res; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectFilesize */ void DetectFilesizeRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectFilesizeParseTest01", DetectFilesizeParseTest01); UtRegisterTest("DetectFilesizeParseTest02", DetectFilesizeParseTest02); UtRegisterTest("DetectFilesizeParseTest03", DetectFilesizeParseTest03); UtRegisterTest("DetectFilesizeParseTest04", DetectFilesizeParseTest04); UtRegisterTest("DetectFilesizeParseTest05", DetectFilesizeParseTest05); UtRegisterTest("DetectFilesizeSetpTest01", DetectFilesizeSetpTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-filestore.c b/src/detect-filestore.c index 47d2ac0b20..9b6c5a1a49 100644 --- a/src/detect-filestore.c +++ b/src/detect-filestore.c @@ -67,7 +67,9 @@ static int DetectFilestorePostMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); static int DetectFilestoreSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFilestoreFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectFilestoreRegisterTests(void); +#endif static int g_file_match_list_id = 0; /** @@ -81,7 +83,9 @@ void DetectFilestoreRegister(void) sigmatch_table[DETECT_FILESTORE].FileMatch = DetectFilestoreMatch; sigmatch_table[DETECT_FILESTORE].Setup = DetectFilestoreSetup; sigmatch_table[DETECT_FILESTORE].Free = DetectFilestoreFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FILESTORE].RegisterTests = DetectFilestoreRegisterTests; +#endif sigmatch_table[DETECT_FILESTORE].flags = SIGMATCH_OPTIONAL_OPT; sigmatch_table[DETECT_FILESTORE_POSTMATCH].name = "__filestore__postmatch__"; @@ -508,11 +512,9 @@ static int DetectFilestoreTest01(void) return result; } -#endif /* UNITTESTS */ void DetectFilestoreRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectFilestoreTest01", DetectFilestoreTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-flow.c b/src/detect-flow.c index 306c8db007..e4ad564352 100644 --- a/src/detect-flow.c +++ b/src/detect-flow.c @@ -51,7 +51,9 @@ static DetectParseRegex parse_regex; int DetectFlowMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectFlowSetup (DetectEngineCtx *, Signature *, const char *); -void DetectFlowRegisterTests(void); +#ifdef UNITTESTS +static void DetectFlowRegisterTests(void); +#endif void DetectFlowFree(DetectEngineCtx *, void *); static int PrefilterSetupFlow(DetectEngineCtx *de_ctx, SigGroupHead *sgh); @@ -68,8 +70,9 @@ void DetectFlowRegister (void) sigmatch_table[DETECT_FLOW].Match = DetectFlowMatch; sigmatch_table[DETECT_FLOW].Setup = DetectFlowSetup; sigmatch_table[DETECT_FLOW].Free = DetectFlowFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FLOW].RegisterTests = DetectFlowRegisterTests; - +#endif sigmatch_table[DETECT_FLOW].SupportsPrefilter = PrefilterFlowIsPrefilterable; sigmatch_table[DETECT_FLOW].SetupPrefilter = PrefilterSetupFlow; @@ -1061,14 +1064,11 @@ static int DetectFlowTestOnlyFragMatch(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectFlow */ -void DetectFlowRegisterTests(void) +static void DetectFlowRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectFlowTestParse01", DetectFlowTestParse01); UtRegisterTest("DetectFlowTestParse02", DetectFlowTestParse02); UtRegisterTest("DetectFlowTestParse03", DetectFlowTestParse03); @@ -1114,5 +1114,5 @@ void DetectFlowRegisterTests(void) UtRegisterTest("DetectFlowTestOnlyFragMatch", DetectFlowTestOnlyFragMatch); UtRegisterTest("DetectFlowSigTest01", DetectFlowSigTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-flowbits.c b/src/detect-flowbits.c index cbe4678411..d5b1cf4e4b 100644 --- a/src/detect-flowbits.c +++ b/src/detect-flowbits.c @@ -55,7 +55,9 @@ int DetectFlowbitMatch (DetectEngineThreadCtx *, Packet *, static int DetectFlowbitSetup (DetectEngineCtx *, Signature *, const char *); static int FlowbitOrAddData(DetectEngineCtx *, DetectFlowbitsData *, char *); void DetectFlowbitFree (DetectEngineCtx *, void *); +#ifdef UNITTESTS void FlowBitsRegisterTests(void); +#endif void DetectFlowbitsRegister (void) { @@ -65,7 +67,9 @@ void DetectFlowbitsRegister (void) sigmatch_table[DETECT_FLOWBITS].Match = DetectFlowbitMatch; sigmatch_table[DETECT_FLOWBITS].Setup = DetectFlowbitSetup; sigmatch_table[DETECT_FLOWBITS].Free = DetectFlowbitFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FLOWBITS].RegisterTests = FlowBitsRegisterTests; +#endif /* this is compatible to ip-only signatures */ sigmatch_table[DETECT_FLOWBITS].flags |= SIGMATCH_IPONLY_COMPAT; @@ -1395,14 +1399,12 @@ static int FlowBitsTestSig11(void) SCFree(p); PASS; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for FlowBits */ void FlowBitsRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("FlowBitsTestParse01", FlowBitsTestParse01); UtRegisterTest("FlowBitsTestSig01", FlowBitsTestSig01); UtRegisterTest("FlowBitsTestSig02", FlowBitsTestSig02); @@ -1415,5 +1417,5 @@ void FlowBitsRegisterTests(void) UtRegisterTest("FlowBitsTestSig09", FlowBitsTestSig09); UtRegisterTest("FlowBitsTestSig10", FlowBitsTestSig10); UtRegisterTest("FlowBitsTestSig11", FlowBitsTestSig11); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-flowint.c b/src/detect-flowint.c index 62ec3de151..db97ee9f49 100644 --- a/src/detect-flowint.c +++ b/src/detect-flowint.c @@ -56,7 +56,9 @@ int DetectFlowintMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectFlowintSetup(DetectEngineCtx *, Signature *, const char *); void DetectFlowintFree(DetectEngineCtx *, void *); -void DetectFlowintRegisterTests(void); +#ifdef UNITTESTS +static void DetectFlowintRegisterTests(void); +#endif void DetectFlowintRegister(void) { @@ -66,8 +68,9 @@ void DetectFlowintRegister(void) sigmatch_table[DETECT_FLOWINT].Match = DetectFlowintMatch; sigmatch_table[DETECT_FLOWINT].Setup = DetectFlowintSetup; sigmatch_table[DETECT_FLOWINT].Free = DetectFlowintFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FLOWINT].RegisterTests = DetectFlowintRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -1300,14 +1303,11 @@ static int DetectFlowintTestPacket03Real(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectFlowint */ void DetectFlowintRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectFlowintTestParseVal01", DetectFlowintTestParseVal01); UtRegisterTest("DetectFlowintTestParseVar01", DetectFlowintTestParseVar01); UtRegisterTest("DetectFlowintTestParseVal02", DetectFlowintTestParseVal02); @@ -1336,5 +1336,5 @@ void DetectFlowintRegisterTests(void) DetectFlowintTestPacket02Real); UtRegisterTest("DetectFlowintTestPacket03Real", DetectFlowintTestPacket03Real); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-flowvar.c b/src/detect-flowvar.c index b7d93ecd22..4e90785e90 100644 --- a/src/detect-flowvar.c +++ b/src/detect-flowvar.c @@ -57,14 +57,12 @@ void DetectFlowvarRegister (void) sigmatch_table[DETECT_FLOWVAR].Match = DetectFlowvarMatch; sigmatch_table[DETECT_FLOWVAR].Setup = DetectFlowvarSetup; sigmatch_table[DETECT_FLOWVAR].Free = DetectFlowvarDataFree; - sigmatch_table[DETECT_FLOWVAR].RegisterTests = NULL; /* post-match for flowvar storage */ sigmatch_table[DETECT_FLOWVAR_POSTMATCH].name = "__flowvar__postmatch__"; sigmatch_table[DETECT_FLOWVAR_POSTMATCH].Match = DetectFlowvarPostMatch; sigmatch_table[DETECT_FLOWVAR_POSTMATCH].Setup = NULL; sigmatch_table[DETECT_FLOWVAR_POSTMATCH].Free = DetectFlowvarDataFree; - sigmatch_table[DETECT_FLOWVAR_POSTMATCH].RegisterTests = NULL; DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } diff --git a/src/detect-fragbits.c b/src/detect-fragbits.c index 632a1298c1..81092a580b 100644 --- a/src/detect-fragbits.c +++ b/src/detect-fragbits.c @@ -74,6 +74,9 @@ static void DetectFragBitsFree(DetectEngineCtx *, void *); static int PrefilterSetupFragBits(DetectEngineCtx *de_ctx, SigGroupHead *sgh); static bool PrefilterFragBitsIsPrefilterable(const Signature *s); +#ifdef UNITTESTS +static void FragBitsRegisterTests(void); +#endif /** * \brief Registration function for fragbits: keyword @@ -87,8 +90,9 @@ void DetectFragBitsRegister (void) sigmatch_table[DETECT_FRAGBITS].Match = DetectFragBitsMatch; sigmatch_table[DETECT_FRAGBITS].Setup = DetectFragBitsSetup; sigmatch_table[DETECT_FRAGBITS].Free = DetectFragBitsFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FRAGBITS].RegisterTests = FragBitsRegisterTests; - +#endif sigmatch_table[DETECT_FRAGBITS].SetupPrefilter = PrefilterSetupFragBits; sigmatch_table[DETECT_FRAGBITS].SupportsPrefilter = PrefilterFragBitsIsPrefilterable; @@ -593,17 +597,15 @@ static int FragBitsTestParse04 (void) SCFree(p); PASS; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for FragBits */ -void FragBitsRegisterTests(void) +static void FragBitsRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("FragBitsTestParse01", FragBitsTestParse01); UtRegisterTest("FragBitsTestParse02", FragBitsTestParse02); UtRegisterTest("FragBitsTestParse03", FragBitsTestParse03); UtRegisterTest("FragBitsTestParse04", FragBitsTestParse04); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-fragbits.h b/src/detect-fragbits.h index d858866703..e2d77cc29b 100644 --- a/src/detect-fragbits.h +++ b/src/detect-fragbits.h @@ -49,10 +49,4 @@ typedef struct DetectFragBitsData_ { void DetectFragBitsRegister (void); -/** - * This function registers unit tests for FragBits - */ - -void FragBitsRegisterTests(void); - #endif /*__DETECT_FRAGBITS_H__ */ diff --git a/src/detect-fragoffset.c b/src/detect-fragoffset.c index ffb46c88a7..0a793267f6 100644 --- a/src/detect-fragoffset.c +++ b/src/detect-fragoffset.c @@ -46,7 +46,9 @@ static DetectParseRegex parse_regex; static int DetectFragOffsetMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectFragOffsetSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS void DetectFragOffsetRegisterTests(void); +#endif void DetectFragOffsetFree(DetectEngineCtx *, void *); static int PrefilterSetupFragOffset(DetectEngineCtx *de_ctx, SigGroupHead *sgh); @@ -63,8 +65,9 @@ void DetectFragOffsetRegister (void) sigmatch_table[DETECT_FRAGOFFSET].Match = DetectFragOffsetMatch; sigmatch_table[DETECT_FRAGOFFSET].Setup = DetectFragOffsetSetup; sigmatch_table[DETECT_FRAGOFFSET].Free = DetectFragOffsetFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FRAGOFFSET].RegisterTests = DetectFragOffsetRegisterTests; - +#endif sigmatch_table[DETECT_FRAGOFFSET].SupportsPrefilter = PrefilterFragOffsetIsPrefilterable; sigmatch_table[DETECT_FRAGOFFSET].SetupPrefilter = PrefilterSetupFragOffset; @@ -446,15 +449,12 @@ end: return result; } -#endif /* UNITTESTS */ void DetectFragOffsetRegisterTests (void) { -#ifdef UNITTESTS UtRegisterTest("DetectFragOffsetParseTest01", DetectFragOffsetParseTest01); UtRegisterTest("DetectFragOffsetParseTest02", DetectFragOffsetParseTest02); UtRegisterTest("DetectFragOffsetParseTest03", DetectFragOffsetParseTest03); UtRegisterTest("DetectFragOffsetMatchTest01", DetectFragOffsetMatchTest01); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-ftpbounce.c b/src/detect-ftpbounce.c index d489580d74..77ac3e9891 100644 --- a/src/detect-ftpbounce.c +++ b/src/detect-ftpbounce.c @@ -52,7 +52,9 @@ static int DetectFtpbounceALMatch(DetectEngineThreadCtx *, const Signature *, const SigMatchCtx *); static int DetectFtpbounceSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectFtpbounceRegisterTests(void); +#endif static int g_ftp_request_list_id = 0; static int InspectFtpRequest(ThreadVars *tv, @@ -71,7 +73,9 @@ void DetectFtpbounceRegister(void) sigmatch_table[DETECT_FTPBOUNCE].desc = "detect FTP bounce attacks"; sigmatch_table[DETECT_FTPBOUNCE].Setup = DetectFtpbounceSetup; sigmatch_table[DETECT_FTPBOUNCE].AppLayerTxMatch = DetectFtpbounceALMatch; +#ifdef UNITTESTS sigmatch_table[DETECT_FTPBOUNCE].RegisterTests = DetectFtpbounceRegisterTests; +#endif sigmatch_table[DETECT_FTPBOUNCE].url = "/rules/ftp-keywords.html#ftpbounce"; sigmatch_table[DETECT_FTPBOUNCE].flags = SIGMATCH_NOOPT; @@ -558,18 +562,15 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectFtpbounce */ -void DetectFtpbounceRegisterTests(void) +static void DetectFtpbounceRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectFtpbounceTestSetup01", DetectFtpbounceTestSetup01); UtRegisterTest("DetectFtpbounceTestALMatch02", DetectFtpbounceTestALMatch02); UtRegisterTest("DetectFtpbounceTestALMatch03", DetectFtpbounceTestALMatch03); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-ftpdata.c b/src/detect-ftpdata.c index 33834278c0..20c670e217 100644 --- a/src/detect-ftpdata.c +++ b/src/detect-ftpdata.c @@ -46,7 +46,9 @@ static int DetectFtpdataMatch(DetectEngineThreadCtx *, const Signature *, const SigMatchCtx *); static int DetectFtpdataSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFtpdataFree (DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectFtpdataRegisterTests (void); +#endif static int DetectEngineInspectFtpdataGeneric(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, @@ -73,8 +75,9 @@ void DetectFtpdataRegister(void) { * shutdown, but also during rule reloads. */ sigmatch_table[DETECT_FTPDATA].Free = DetectFtpdataFree; /* registers unittests into the system */ +#ifdef UNITTESTS sigmatch_table[DETECT_FTPDATA].RegisterTests = DetectFtpdataRegisterTests; - +#endif DetectAppLayerInspectEngineRegister("ftpdata_command", ALPROTO_FTPDATA, SIG_FLAG_TOSERVER, 0, DetectEngineInspectFtpdataGeneric); @@ -251,15 +254,13 @@ static int DetectFtpdataSignatureTest01(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectFtpdata */ -void DetectFtpdataRegisterTests(void) { -#ifdef UNITTESTS +static void DetectFtpdataRegisterTests(void) +{ UtRegisterTest("DetectFtpdataParseTest01", DetectFtpdataParseTest01); UtRegisterTest("DetectFtpdataSignatureTest01", DetectFtpdataSignatureTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-geoip.c b/src/detect-geoip.c index b7a1fefea0..b72b87cdba 100644 --- a/src/detect-geoip.c +++ b/src/detect-geoip.c @@ -59,7 +59,6 @@ void DetectGeoipRegister(void) sigmatch_table[DETECT_GEOIP].url = "/rules/header-keywords.html#geoip"; sigmatch_table[DETECT_GEOIP].Setup = DetectGeoipSetupNoSupport; sigmatch_table[DETECT_GEOIP].Free = NULL; - sigmatch_table[DETECT_GEOIP].RegisterTests = NULL; } #else /* HAVE_GEOIP */ @@ -69,7 +68,9 @@ void DetectGeoipRegister(void) static int DetectGeoipMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectGeoipSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectGeoipRegisterTests(void); +#endif static void DetectGeoipDataFree(DetectEngineCtx *, void *); /** @@ -84,7 +85,9 @@ void DetectGeoipRegister(void) sigmatch_table[DETECT_GEOIP].Match = DetectGeoipMatch; sigmatch_table[DETECT_GEOIP].Setup = DetectGeoipSetup; sigmatch_table[DETECT_GEOIP].Free = DetectGeoipDataFree; +#ifdef UNITTESTS sigmatch_table[DETECT_GEOIP].RegisterTests = DetectGeoipRegisterTests; +#endif } /** @@ -533,17 +536,12 @@ static int GeoipParseTest07(void) GEOIP_MATCH_BOTH_FLAG | GEOIP_MATCH_NEGATED); } - - -#endif /* UNITTESTS */ - /** * \internal * \brief This function registers unit tests for DetectGeoip */ static void DetectGeoipRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("GeoipParseTest01", GeoipParseTest01); UtRegisterTest("GeoipParseTest02", GeoipParseTest02); UtRegisterTest("GeoipParseTest03", GeoipParseTest03); @@ -551,8 +549,6 @@ static void DetectGeoipRegisterTests(void) UtRegisterTest("GeoipParseTest05", GeoipParseTest05); UtRegisterTest("GeoipParseTest06", GeoipParseTest06); UtRegisterTest("GeoipParseTest07", GeoipParseTest07); - -#endif /* UNITTESTS */ } - -#endif /* HAVE_GEOIP */ +#endif /* UNITTESTS */ +#endif /* HAVE_GEOIP */ \ No newline at end of file diff --git a/src/detect-gid.c b/src/detect-gid.c index 684dfed3c7..313e7b7d38 100644 --- a/src/detect-gid.c +++ b/src/detect-gid.c @@ -37,6 +37,9 @@ #include "util-debug.h" static int DetectGidSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS +static void GidRegisterTests(void); +#endif /** * \brief Registration function for gid: keyword @@ -50,7 +53,9 @@ void DetectGidRegister (void) sigmatch_table[DETECT_GID].Match = NULL; sigmatch_table[DETECT_GID].Setup = DetectGidSetup; sigmatch_table[DETECT_GID].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_GID].RegisterTests = GidRegisterTests; +#endif } /** @@ -166,16 +171,14 @@ end: DetectEngineCtxFree(de_ctx); return result; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for Gid */ -void GidRegisterTests(void) +static void GidRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("GidTestParse01", GidTestParse01); UtRegisterTest("GidTestParse02", GidTestParse02); UtRegisterTest("GidTestParse03", GidTestParse03); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-gid.h b/src/detect-gid.h index d98d6edcb4..aa9a8f9d1f 100644 --- a/src/detect-gid.h +++ b/src/detect-gid.h @@ -36,10 +36,4 @@ void DetectGidRegister (void); -/** - * This function registers unit tests for Gid - */ - -void GidRegisterTests(void); - -#endif /*__DETECT_GID_H__ */ +#endif /*__DETECT_GID_H__ */ \ No newline at end of file diff --git a/src/detect-hostbits.c b/src/detect-hostbits.c index fa20c4f74b..35574150bb 100644 --- a/src/detect-hostbits.c +++ b/src/detect-hostbits.c @@ -71,7 +71,9 @@ static int DetectHostbitMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectHostbitSetup (DetectEngineCtx *, Signature *, const char *); void DetectHostbitFree (DetectEngineCtx *, void *); +#ifdef UNITTESTS void HostBitsRegisterTests(void); +#endif void DetectHostbitsRegister (void) { @@ -81,7 +83,9 @@ void DetectHostbitsRegister (void) sigmatch_table[DETECT_HOSTBITS].Match = DetectHostbitMatch; sigmatch_table[DETECT_HOSTBITS].Setup = DetectHostbitSetup; sigmatch_table[DETECT_HOSTBITS].Free = DetectHostbitFree; +#ifdef UNITTESTS sigmatch_table[DETECT_HOSTBITS].RegisterTests = HostBitsRegisterTests; +#endif /* this is compatible to ip-only signatures */ sigmatch_table[DETECT_HOSTBITS].flags |= SIGMATCH_IPONLY_COMPAT; @@ -1223,14 +1227,12 @@ static int HostBitsTestSig08(void) SCFree(p); PASS; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for HostBits */ void HostBitsRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("HostBitsTestParse01", HostBitsTestParse01); UtRegisterTest("HostBitsTestSig01", HostBitsTestSig01); UtRegisterTest("HostBitsTestSig02", HostBitsTestSig02); @@ -1244,5 +1246,5 @@ void HostBitsRegisterTests(void) #endif UtRegisterTest("HostBitsTestSig07", HostBitsTestSig07); UtRegisterTest("HostBitsTestSig08", HostBitsTestSig08); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-http-request-line.c b/src/detect-http-request-line.c index 101aa4a950..963ca3d08f 100644 --- a/src/detect-http-request-line.c +++ b/src/detect-http-request-line.c @@ -61,7 +61,9 @@ #include "detect-http-request-line.h" static int DetectHttpRequestLineSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectHttpRequestLineRegisterTests(void); +#endif static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx, const DetectEngineTransforms *transforms, Flow *_f, const uint8_t _flow_flags, @@ -79,8 +81,9 @@ void DetectHttpRequestLineRegister(void) sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].url = "/rules/http-keywords.html#http-request-line"; sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].Match = NULL; sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].Setup = DetectHttpRequestLineSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].RegisterTests = DetectHttpRequestLineRegisterTests; - +#endif sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].flags |= SIGMATCH_NOOPT|SIGMATCH_INFO_STICKY_BUFFER; DetectAppLayerInspectEngineRegister2("http_request_line", @@ -326,18 +329,13 @@ static int DetectHttpRequestLineTest03(void) PASS; } -#endif /* UNITTESTS */ - static void DetectHttpRequestLineRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectHttpRequestLineTest01", DetectHttpRequestLineTest01); UtRegisterTest("DetectHttpRequestLineTest02", DetectHttpRequestLineTest02); UtRegisterTest("DetectHttpRequestLineTest03", DetectHttpRequestLineTest03); -#endif /* UNITTESTS */ - - return; } +#endif /* UNITTESTS */ /** * @} */ diff --git a/src/detect-http-response-line.c b/src/detect-http-response-line.c index 4fe43da52c..42d7c9a283 100644 --- a/src/detect-http-response-line.c +++ b/src/detect-http-response-line.c @@ -61,7 +61,9 @@ #include "detect-http-response-line.h" static int DetectHttpResponseLineSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectHttpResponseLineRegisterTests(void); +#endif static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx, const DetectEngineTransforms *transforms, Flow *_f, const uint8_t _flow_flags, @@ -78,8 +80,9 @@ void DetectHttpResponseLineRegister(void) sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].desc = "content modifier to match only on the HTTP response line"; sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].url = "/rules/http-keywords.html#http-response-line"; sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].Setup = DetectHttpResponseLineSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].RegisterTests = DetectHttpResponseLineRegisterTests; - +#endif sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].flags |= SIGMATCH_NOOPT|SIGMATCH_INFO_STICKY_BUFFER; DetectAppLayerInspectEngineRegister2("http_response_line", @@ -256,17 +259,12 @@ static int DetectHttpResponseLineTest02(void) PASS; } -#endif /* UNITTESTS */ - void DetectHttpResponseLineRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectHttpResponseLineTest01", DetectHttpResponseLineTest01); UtRegisterTest("DetectHttpResponseLineTest02", DetectHttpResponseLineTest02); -#endif /* UNITTESTS */ - - return; } +#endif /* UNITTESTS */ /** * @} */ diff --git a/src/detect-icmp-id.c b/src/detect-icmp-id.c index 11ea25483e..c97be24ae3 100644 --- a/src/detect-icmp-id.c +++ b/src/detect-icmp-id.c @@ -45,7 +45,9 @@ static DetectParseRegex parse_regex; static int DetectIcmpIdMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectIcmpIdSetup(DetectEngineCtx *, Signature *, const char *); -void DetectIcmpIdRegisterTests(void); +#ifdef UNITTESTS +static void DetectIcmpIdRegisterTests(void); +#endif void DetectIcmpIdFree(DetectEngineCtx *, void *); static int PrefilterSetupIcmpId(DetectEngineCtx *de_ctx, SigGroupHead *sgh); static bool PrefilterIcmpIdIsPrefilterable(const Signature *s); @@ -61,8 +63,9 @@ void DetectIcmpIdRegister (void) sigmatch_table[DETECT_ICMP_ID].Match = DetectIcmpIdMatch; sigmatch_table[DETECT_ICMP_ID].Setup = DetectIcmpIdSetup; sigmatch_table[DETECT_ICMP_ID].Free = DetectIcmpIdFree; +#ifdef UNITTESTS sigmatch_table[DETECT_ICMP_ID].RegisterTests = DetectIcmpIdRegisterTests; - +#endif sigmatch_table[DETECT_ICMP_ID].SupportsPrefilter = PrefilterIcmpIdIsPrefilterable; sigmatch_table[DETECT_ICMP_ID].SetupPrefilter = PrefilterSetupIcmpId; @@ -533,11 +536,9 @@ end: SCFree(p); return result; } -#endif /* UNITTESTS */ -void DetectIcmpIdRegisterTests (void) +static void DetectIcmpIdRegisterTests (void) { -#ifdef UNITTESTS UtRegisterTest("DetectIcmpIdParseTest01", DetectIcmpIdParseTest01); UtRegisterTest("DetectIcmpIdParseTest02", DetectIcmpIdParseTest02); UtRegisterTest("DetectIcmpIdParseTest03", DetectIcmpIdParseTest03); @@ -545,6 +546,5 @@ void DetectIcmpIdRegisterTests (void) UtRegisterTest("DetectIcmpIdParseTest05", DetectIcmpIdParseTest05); UtRegisterTest("DetectIcmpIdMatchTest01", DetectIcmpIdMatchTest01); UtRegisterTest("DetectIcmpIdMatchTest02", DetectIcmpIdMatchTest02); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ diff --git a/src/detect-icmp-seq.c b/src/detect-icmp-seq.c index 06ae828953..ad15141db2 100644 --- a/src/detect-icmp-seq.c +++ b/src/detect-icmp-seq.c @@ -45,7 +45,9 @@ static DetectParseRegex parse_regex; static int DetectIcmpSeqMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectIcmpSeqSetup(DetectEngineCtx *, Signature *, const char *); -void DetectIcmpSeqRegisterTests(void); +#ifdef UNITTESTS +static void DetectIcmpSeqRegisterTests(void); +#endif void DetectIcmpSeqFree(DetectEngineCtx *, void *); static int PrefilterSetupIcmpSeq(DetectEngineCtx *de_ctx, SigGroupHead *sgh); static bool PrefilterIcmpSeqIsPrefilterable(const Signature *s); @@ -61,8 +63,9 @@ void DetectIcmpSeqRegister (void) sigmatch_table[DETECT_ICMP_SEQ].Match = DetectIcmpSeqMatch; sigmatch_table[DETECT_ICMP_SEQ].Setup = DetectIcmpSeqSetup; sigmatch_table[DETECT_ICMP_SEQ].Free = DetectIcmpSeqFree; +#ifdef UNITTESTS sigmatch_table[DETECT_ICMP_SEQ].RegisterTests = DetectIcmpSeqRegisterTests; - +#endif sigmatch_table[DETECT_ICMP_SEQ].SupportsPrefilter = PrefilterIcmpSeqIsPrefilterable; sigmatch_table[DETECT_ICMP_SEQ].SetupPrefilter = PrefilterSetupIcmpSeq; @@ -427,17 +430,13 @@ cleanup: UTHFreePackets(&p, 1); end: return result; - } -#endif /* UNITTESTS */ -void DetectIcmpSeqRegisterTests (void) +static void DetectIcmpSeqRegisterTests (void) { -#ifdef UNITTESTS UtRegisterTest("DetectIcmpSeqParseTest01", DetectIcmpSeqParseTest01); UtRegisterTest("DetectIcmpSeqParseTest02", DetectIcmpSeqParseTest02); UtRegisterTest("DetectIcmpSeqParseTest03", DetectIcmpSeqParseTest03); UtRegisterTest("DetectIcmpSeqMatchTest01", DetectIcmpSeqMatchTest01); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-icode.c b/src/detect-icode.c index f174997a30..a0cadbdacf 100644 --- a/src/detect-icode.c +++ b/src/detect-icode.c @@ -48,7 +48,9 @@ static DetectParseRegex parse_regex; static int DetectICodeMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectICodeSetup(DetectEngineCtx *, Signature *, const char *); -void DetectICodeRegisterTests(void); +#ifdef UNITTESTS +static void DetectICodeRegisterTests(void); +#endif void DetectICodeFree(DetectEngineCtx *, void *); static int PrefilterSetupICode(DetectEngineCtx *de_ctx, SigGroupHead *sgh); @@ -65,8 +67,9 @@ void DetectICodeRegister (void) sigmatch_table[DETECT_ICODE].Match = DetectICodeMatch; sigmatch_table[DETECT_ICODE].Setup = DetectICodeSetup; sigmatch_table[DETECT_ICODE].Free = DetectICodeFree; +#ifdef UNITTESTS sigmatch_table[DETECT_ICODE].RegisterTests = DetectICodeRegisterTests; - +#endif sigmatch_table[DETECT_ICODE].SupportsPrefilter = PrefilterICodeIsPrefilterable; sigmatch_table[DETECT_ICODE].SetupPrefilter = PrefilterSetupICode; @@ -572,14 +575,11 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectICode */ void DetectICodeRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectICodeParseTest01", DetectICodeParseTest01); UtRegisterTest("DetectICodeParseTest02", DetectICodeParseTest02); UtRegisterTest("DetectICodeParseTest03", DetectICodeParseTest03); @@ -589,5 +589,5 @@ void DetectICodeRegisterTests(void) UtRegisterTest("DetectICodeParseTest07", DetectICodeParseTest07); UtRegisterTest("DetectICodeParseTest08", DetectICodeParseTest08); UtRegisterTest("DetectICodeMatchTest01", DetectICodeMatchTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-id.c b/src/detect-id.c index a9d2d1ce1b..d5d3eebf0f 100644 --- a/src/detect-id.c +++ b/src/detect-id.c @@ -52,7 +52,9 @@ static DetectParseRegex parse_regex; static int DetectIdMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectIdSetup (DetectEngineCtx *, Signature *, const char *); -void DetectIdRegisterTests(void); +#ifdef UNITTESTS +static void DetectIdRegisterTests(void); +#endif void DetectIdFree(DetectEngineCtx *, void *); static int PrefilterSetupId(DetectEngineCtx *de_ctx, SigGroupHead *sgh); @@ -69,8 +71,9 @@ void DetectIdRegister (void) sigmatch_table[DETECT_ID].Match = DetectIdMatch; sigmatch_table[DETECT_ID].Setup = DetectIdSetup; sigmatch_table[DETECT_ID].Free = DetectIdFree; +#ifdef UNITTESTS sigmatch_table[DETECT_ID].RegisterTests = DetectIdRegisterTests; - +#endif sigmatch_table[DETECT_ID].SupportsPrefilter = PrefilterIdIsPrefilterable; sigmatch_table[DETECT_ID].SetupPrefilter = PrefilterSetupId; @@ -388,19 +391,17 @@ static int DetectIdTestMatch01(void) end: return result; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for DetectId */ void DetectIdRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectIdTestParse01", DetectIdTestParse01); UtRegisterTest("DetectIdTestParse02", DetectIdTestParse02); UtRegisterTest("DetectIdTestParse03", DetectIdTestParse03); UtRegisterTest("DetectIdTestParse04", DetectIdTestParse04); UtRegisterTest("DetectIdTestMatch01", DetectIdTestMatch01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-ipopts.c b/src/detect-ipopts.c index 7d0282f83e..3867e56894 100644 --- a/src/detect-ipopts.c +++ b/src/detect-ipopts.c @@ -45,7 +45,9 @@ static DetectParseRegex parse_regex; static int DetectIpOptsMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectIpOptsSetup (DetectEngineCtx *, Signature *, const char *); -void IpOptsRegisterTests(void); +#ifdef UNITTESTS +static void IpOptsRegisterTests(void); +#endif void DetectIpOptsFree(DetectEngineCtx *, void *); /** @@ -59,8 +61,9 @@ void DetectIpOptsRegister (void) sigmatch_table[DETECT_IPOPTS].Match = DetectIpOptsMatch; sigmatch_table[DETECT_IPOPTS].Setup = DetectIpOptsSetup; sigmatch_table[DETECT_IPOPTS].Free = DetectIpOptsFree; +#ifdef UNITTESTS sigmatch_table[DETECT_IPOPTS].RegisterTests = IpOptsRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -349,17 +352,15 @@ error: SCFree(p); return 1; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for IpOpts */ void IpOptsRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("IpOptsTestParse01", IpOptsTestParse01); UtRegisterTest("IpOptsTestParse02", IpOptsTestParse02); UtRegisterTest("IpOptsTestParse03", IpOptsTestParse03); UtRegisterTest("IpOptsTestParse04", IpOptsTestParse04); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-ipproto.c b/src/detect-ipproto.c index 023aa02c84..eefed9845f 100644 --- a/src/detect-ipproto.c +++ b/src/detect-ipproto.c @@ -51,7 +51,9 @@ static DetectParseRegex parse_regex; static int DetectIPProtoSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectIPProtoRegisterTests(void); +#endif static void DetectIPProtoFree(DetectEngineCtx *, void *); void DetectIPProtoRegister(void) @@ -62,7 +64,9 @@ void DetectIPProtoRegister(void) sigmatch_table[DETECT_IPPROTO].Match = NULL; sigmatch_table[DETECT_IPPROTO].Setup = DetectIPProtoSetup; sigmatch_table[DETECT_IPPROTO].Free = DetectIPProtoFree; +#ifdef UNITTESTS sigmatch_table[DETECT_IPPROTO].RegisterTests = DetectIPProtoRegisterTests; +#endif sigmatch_table[DETECT_IPPROTO].flags = SIGMATCH_QUOTES_OPTIONAL; DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); @@ -2066,15 +2070,12 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \internal * \brief Register ip_proto tests. */ static void DetectIPProtoRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectIPProtoTestParse01", DetectIPProtoTestParse01); UtRegisterTest("DetectIPProtoTestParse02", DetectIPProtoTestParse02); UtRegisterTest("DetectIPProtoTestSetup01", DetectIPProtoTestSetup01); @@ -2119,5 +2120,5 @@ static void DetectIPProtoRegisterTests(void) UtRegisterTest("DetectIPProtoTestSig1", DetectIPProtoTestSig1); UtRegisterTest("DetectIPProtoTestSig2", DetectIPProtoTestSig2); UtRegisterTest("DetectIPProtoTestSig3", DetectIPProtoTestSig3); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-iprep.c b/src/detect-iprep.c index e418fb2fd6..9904b5a1cd 100644 --- a/src/detect-iprep.c +++ b/src/detect-iprep.c @@ -56,7 +56,9 @@ static int DetectIPRepMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectIPRepSetup (DetectEngineCtx *, Signature *, const char *); void DetectIPRepFree (DetectEngineCtx *, void *); -void IPRepRegisterTests(void); +#ifdef UNITTESTS +static void IPRepRegisterTests(void); +#endif void DetectIPRepRegister (void) { @@ -66,7 +68,9 @@ void DetectIPRepRegister (void) sigmatch_table[DETECT_IPREP].Match = DetectIPRepMatch; sigmatch_table[DETECT_IPREP].Setup = DetectIPRepSetup; sigmatch_table[DETECT_IPREP].Free = DetectIPRepFree; +#ifdef UNITTESTS sigmatch_table[DETECT_IPREP].RegisterTests = IPRepRegisterTests; +#endif /* this is compatible to ip-only signatures */ sigmatch_table[DETECT_IPREP].flags |= SIGMATCH_IPONLY_COMPAT; @@ -997,14 +1001,12 @@ end: HostShutdown(); return result; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for IPRep */ void IPRepRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectIPRepTest01", DetectIPRepTest01); UtRegisterTest("DetectIPRepTest02", DetectIPRepTest02); UtRegisterTest("DetectIPRepTest03", DetectIPRepTest03); @@ -1014,5 +1016,5 @@ void IPRepRegisterTests(void) UtRegisterTest("DetectIPRepTest07", DetectIPRepTest07); UtRegisterTest("DetectIPRepTest08", DetectIPRepTest08); UtRegisterTest("DetectIPRepTest09", DetectIPRepTest09); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-isdataat.c b/src/detect-isdataat.c index c75ae91354..e581772115 100644 --- a/src/detect-isdataat.c +++ b/src/detect-isdataat.c @@ -54,7 +54,9 @@ static DetectParseRegex parse_regex; int DetectIsdataatSetup (DetectEngineCtx *, Signature *, const char *); -void DetectIsdataatRegisterTests(void); +#ifdef UNITTESTS +static void DetectIsdataatRegisterTests(void); +#endif void DetectIsdataatFree(DetectEngineCtx *, void *); static int DetectEndsWithSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr); @@ -71,8 +73,9 @@ void DetectIsdataatRegister(void) sigmatch_table[DETECT_ISDATAAT].Match = NULL; sigmatch_table[DETECT_ISDATAAT].Setup = DetectIsdataatSetup; sigmatch_table[DETECT_ISDATAAT].Free = DetectIsdataatFree; +#ifdef UNITTESTS sigmatch_table[DETECT_ISDATAAT].RegisterTests = DetectIsdataatRegisterTests; - +#endif sigmatch_table[DETECT_ENDS_WITH].name = "endswith"; sigmatch_table[DETECT_ENDS_WITH].desc = "make sure the previous content matches exactly at the end of the buffer"; sigmatch_table[DETECT_ENDS_WITH].url = "/rules/payload-keywords.html#endswith"; @@ -667,14 +670,12 @@ static int DetectIsdataatTestPacket03 (void) end: return result; } -#endif /** * \brief this function registers unit tests for DetectIsdataat */ void DetectIsdataatRegisterTests(void) { -#ifdef UNITTESTS g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data"); UtRegisterTest("DetectIsdataatTestParse01", DetectIsdataatTestParse01); @@ -687,5 +688,5 @@ void DetectIsdataatRegisterTests(void) UtRegisterTest("DetectIsdataatTestPacket01", DetectIsdataatTestPacket01); UtRegisterTest("DetectIsdataatTestPacket02", DetectIsdataatTestPacket02); UtRegisterTest("DetectIsdataatTestPacket03", DetectIsdataatTestPacket03); -#endif } +#endif \ No newline at end of file diff --git a/src/detect-itype.c b/src/detect-itype.c index 4e059cc18e..ba0f2f1397 100644 --- a/src/detect-itype.c +++ b/src/detect-itype.c @@ -48,7 +48,9 @@ static DetectParseRegex parse_regex; static int DetectITypeMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectITypeSetup(DetectEngineCtx *, Signature *, const char *); -void DetectITypeRegisterTests(void); +#ifdef UNITTESTS +static void DetectITypeRegisterTests(void); +#endif void DetectITypeFree(DetectEngineCtx *, void *); static int PrefilterSetupIType(DetectEngineCtx *de_ctx, SigGroupHead *sgh); @@ -65,8 +67,9 @@ void DetectITypeRegister (void) sigmatch_table[DETECT_ITYPE].Match = DetectITypeMatch; sigmatch_table[DETECT_ITYPE].Setup = DetectITypeSetup; sigmatch_table[DETECT_ITYPE].Free = DetectITypeFree; +#ifdef UNITTESTS sigmatch_table[DETECT_ITYPE].RegisterTests = DetectITypeRegisterTests; - +#endif sigmatch_table[DETECT_ITYPE].SupportsPrefilter = PrefilterITypeIsPrefilterable; sigmatch_table[DETECT_ITYPE].SetupPrefilter = PrefilterSetupIType; @@ -577,15 +580,11 @@ end: return result; } - -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectIType */ void DetectITypeRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectITypeParseTest01", DetectITypeParseTest01); UtRegisterTest("DetectITypeParseTest02", DetectITypeParseTest02); UtRegisterTest("DetectITypeParseTest03", DetectITypeParseTest03); @@ -595,5 +594,5 @@ void DetectITypeRegisterTests(void) UtRegisterTest("DetectITypeParseTest07", DetectITypeParseTest07); UtRegisterTest("DetectITypeParseTest08", DetectITypeParseTest08); UtRegisterTest("DetectITypeMatchTest01", DetectITypeMatchTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-krb5-errcode.c b/src/detect-krb5-errcode.c index 1b7de6f214..8272e6d373 100644 --- a/src/detect-krb5-errcode.c +++ b/src/detect-krb5-errcode.c @@ -45,7 +45,9 @@ static int DetectKrb5ErrCodeMatch (DetectEngineThreadCtx *, Flow *, const SigMatchCtx *); static int DetectKrb5ErrCodeSetup (DetectEngineCtx *, Signature *, const char *); static void DetectKrb5ErrCodeFree (DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectKrb5ErrCodeRegisterTests (void); +#endif static int DetectEngineInspectKRB5Generic(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, @@ -60,7 +62,8 @@ static int g_krb5_err_code_list_id = 0; * * This function is called once in the 'lifetime' of the engine. */ -void DetectKrb5ErrCodeRegister(void) { +void DetectKrb5ErrCodeRegister(void) +{ sigmatch_table[DETECT_AL_KRB5_ERRCODE].name = "krb5_err_code"; sigmatch_table[DETECT_AL_KRB5_ERRCODE].desc = "match Kerberos 5 error code"; sigmatch_table[DETECT_AL_KRB5_ERRCODE].url = "/rules/kerberos-keywords.html#krb5-err-code"; @@ -68,8 +71,9 @@ void DetectKrb5ErrCodeRegister(void) { sigmatch_table[DETECT_AL_KRB5_ERRCODE].AppLayerTxMatch = DetectKrb5ErrCodeMatch; sigmatch_table[DETECT_AL_KRB5_ERRCODE].Setup = DetectKrb5ErrCodeSetup; sigmatch_table[DETECT_AL_KRB5_ERRCODE].Free = DetectKrb5ErrCodeFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_KRB5_ERRCODE].RegisterTests = DetectKrb5ErrCodeRegisterTests; - +#endif DetectAppLayerInspectEngineRegister("krb5_err_code", ALPROTO_KRB5, SIG_FLAG_TOSERVER, 0, DetectEngineInspectKRB5Generic); @@ -223,7 +227,6 @@ static void DetectKrb5ErrCodeFree(DetectEngineCtx *de_ctx, void *ptr) { } #ifdef UNITTESTS - /** * \test description of the test */ @@ -249,15 +252,13 @@ static int DetectKrb5ErrCodeSignatureTest01 (void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectKrb5ErrCode */ -static void DetectKrb5ErrCodeRegisterTests(void) { -#ifdef UNITTESTS +static void DetectKrb5ErrCodeRegisterTests(void) +{ UtRegisterTest("DetectKrb5ErrCodeParseTest01", DetectKrb5ErrCodeParseTest01); UtRegisterTest("DetectKrb5ErrCodeSignatureTest01", DetectKrb5ErrCodeSignatureTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-krb5-msgtype.c b/src/detect-krb5-msgtype.c index a7b71a829a..fa730d88ed 100644 --- a/src/detect-krb5-msgtype.c +++ b/src/detect-krb5-msgtype.c @@ -45,7 +45,9 @@ static int DetectKrb5MsgTypeMatch (DetectEngineThreadCtx *, Flow *, const SigMatchCtx *); static int DetectKrb5MsgTypeSetup (DetectEngineCtx *, Signature *, const char *); static void DetectKrb5MsgTypeFree (DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectKrb5MsgTypeRegisterTests (void); +#endif static int DetectEngineInspectKRB5Generic(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, @@ -60,7 +62,8 @@ static int g_krb5_msg_type_list_id = 0; * * This function is called once in the 'lifetime' of the engine. */ -void DetectKrb5MsgTypeRegister(void) { +void DetectKrb5MsgTypeRegister(void) +{ sigmatch_table[DETECT_AL_KRB5_MSGTYPE].name = "krb5_msg_type"; sigmatch_table[DETECT_AL_KRB5_MSGTYPE].desc = "match Kerberos 5 message type"; sigmatch_table[DETECT_AL_KRB5_MSGTYPE].url = "/rules/kerberos-keywords.html#krb5-msg-type"; @@ -68,8 +71,9 @@ void DetectKrb5MsgTypeRegister(void) { sigmatch_table[DETECT_AL_KRB5_MSGTYPE].AppLayerTxMatch = DetectKrb5MsgTypeMatch; sigmatch_table[DETECT_AL_KRB5_MSGTYPE].Setup = DetectKrb5MsgTypeSetup; sigmatch_table[DETECT_AL_KRB5_MSGTYPE].Free = DetectKrb5MsgTypeFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_KRB5_MSGTYPE].RegisterTests = DetectKrb5MsgTypeRegisterTests; - +#endif DetectAppLayerInspectEngineRegister("krb5_msg_type", ALPROTO_KRB5, SIG_FLAG_TOSERVER, 0, DetectEngineInspectKRB5Generic); @@ -246,15 +250,13 @@ static int DetectKrb5MsgTypeSignatureTest01 (void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectKrb5MsgType */ -static void DetectKrb5MsgTypeRegisterTests(void) { -#ifdef UNITTESTS +static void DetectKrb5MsgTypeRegisterTests(void) +{ UtRegisterTest("DetectKrb5MsgTypeParseTest01", DetectKrb5MsgTypeParseTest01); UtRegisterTest("DetectKrb5MsgTypeSignatureTest01", DetectKrb5MsgTypeSignatureTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-l3proto.c b/src/detect-l3proto.c index 7766231fd9..87ef8b6cf8 100644 --- a/src/detect-l3proto.c +++ b/src/detect-l3proto.c @@ -47,8 +47,9 @@ #include "util-debug.h" static int DetectL3ProtoSetup(DetectEngineCtx *, Signature *, const char *); - -void DetectL3protoRegisterTests(void); +#ifdef UNITTESTS +static void DetectL3protoRegisterTests(void); +#endif void DetectL3ProtoRegister(void) { @@ -56,9 +57,9 @@ void DetectL3ProtoRegister(void) sigmatch_table[DETECT_L3PROTO].Match = NULL; sigmatch_table[DETECT_L3PROTO].Setup = DetectL3ProtoSetup; sigmatch_table[DETECT_L3PROTO].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_L3PROTO].RegisterTests = DetectL3protoRegisterTests; - - return; +#endif } /** * \internal @@ -359,17 +360,13 @@ end: return result; } - -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectL3proto */ -void DetectL3protoRegisterTests(void) +static void DetectL3protoRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectL3protoTestSig1", DetectL3protoTestSig1); UtRegisterTest("DetectL3protoTestSig2", DetectL3protoTestSig2); UtRegisterTest("DetectL3protoTestSig3", DetectL3protoTestSig3); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-lua.c b/src/detect-lua.c index 2db5e68c94..337dcefd90 100644 --- a/src/detect-lua.c +++ b/src/detect-lua.c @@ -80,7 +80,6 @@ void DetectLuaRegister(void) sigmatch_table[DETECT_LUA].url = "/rules/rule-lua-scripting.html"; sigmatch_table[DETECT_LUA].Setup = DetectLuaSetupNoSupport; sigmatch_table[DETECT_LUA].Free = NULL; - sigmatch_table[DETECT_LUA].RegisterTests = NULL; sigmatch_table[DETECT_LUA].flags = SIGMATCH_NOT_BUILT; SCLogDebug("registering lua rule option"); @@ -98,7 +97,9 @@ static int DetectLuaAppTxMatch (DetectEngineThreadCtx *det_ctx, void *state, void *txv, const Signature *s, const SigMatchCtx *ctx); static int DetectLuaSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectLuaRegisterTests(void); +#endif static void DetectLuaFree(DetectEngineCtx *, void *); static int g_smtp_generic_list_id = 0; @@ -121,8 +122,9 @@ void DetectLuaRegister(void) sigmatch_table[DETECT_LUA].AppLayerTxMatch = DetectLuaAppTxMatch; sigmatch_table[DETECT_LUA].Setup = DetectLuaSetup; sigmatch_table[DETECT_LUA].Free = DetectLuaFree; +#ifdef UNITTESTS sigmatch_table[DETECT_LUA].RegisterTests = DetectLuaRegisterTests; - +#endif g_smtp_generic_list_id = DetectBufferTypeRegister("smtp_generic"); DetectAppLayerInspectEngineRegister("smtp_generic", @@ -2051,18 +2053,14 @@ end: return result; } -#endif - void DetectLuaRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("LuaMatchTest01", LuaMatchTest01); UtRegisterTest("LuaMatchTest02", LuaMatchTest02); UtRegisterTest("LuaMatchTest03", LuaMatchTest03); UtRegisterTest("LuaMatchTest04", LuaMatchTest04); UtRegisterTest("LuaMatchTest05", LuaMatchTest05); UtRegisterTest("LuaMatchTest06", LuaMatchTest06); -#endif } - -#endif /* HAVE_LUAJIT */ +#endif +#endif /* HAVE_LUAJIT */ \ No newline at end of file diff --git a/src/detect-mark.c b/src/detect-mark.c index 0fd5be2557..081f42dc9b 100644 --- a/src/detect-mark.c +++ b/src/detect-mark.c @@ -45,6 +45,9 @@ static int DetectMarkSetup (DetectEngineCtx *, Signature *, const char *); static int DetectMarkPacket(DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); void DetectMarkDataFree(DetectEngineCtx *, void *ptr); +#if defined UNITTESTS && defined NFQ +static void MarkRegisterTests(void); +#endif /** * \brief Registration function for nfq_set_mark: keyword @@ -56,8 +59,9 @@ void DetectMarkRegister (void) sigmatch_table[DETECT_MARK].Match = DetectMarkPacket; sigmatch_table[DETECT_MARK].Setup = DetectMarkSetup; sigmatch_table[DETECT_MARK].Free = DetectMarkDataFree; +#if defined UNITTESTS && defined NFQ sigmatch_table[DETECT_MARK].RegisterTests = MarkRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -326,19 +330,14 @@ static int MarkTestParse04 (void) return 0; } - - -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for Mark */ -void MarkRegisterTests(void) +static void MarkRegisterTests(void) { -#if defined UNITTESTS && defined NFQ UtRegisterTest("MarkTestParse01", MarkTestParse01); UtRegisterTest("MarkTestParse02", MarkTestParse02); UtRegisterTest("MarkTestParse03", MarkTestParse03); UtRegisterTest("MarkTestParse04", MarkTestParse04); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-mark.h b/src/detect-mark.h index 3c3b8593d5..1c456a4843 100644 --- a/src/detect-mark.h +++ b/src/detect-mark.h @@ -52,10 +52,4 @@ typedef struct DetectMarkData_ { void DetectMarkRegister (void); -/** - * This function registers unit tests for Mark - */ - -void MarkRegisterTests(void); - #endif /*__DETECT_MARK_H__ */ diff --git a/src/detect-metadata.c b/src/detect-metadata.c index cceff6163b..0195521c63 100644 --- a/src/detect-metadata.c +++ b/src/detect-metadata.c @@ -35,7 +35,9 @@ #include "util-unittest.h" static int DetectMetadataSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectMetadataRegisterTests(void); +#endif void DetectMetadataRegister (void) { @@ -45,7 +47,9 @@ void DetectMetadataRegister (void) sigmatch_table[DETECT_METADATA].Match = NULL; sigmatch_table[DETECT_METADATA].Setup = DetectMetadataSetup; sigmatch_table[DETECT_METADATA].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_METADATA].RegisterTests = DetectMetadataRegisterTests; +#endif } /** @@ -209,16 +213,12 @@ static int DetectMetadataParseTest02(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectCipService */ static void DetectMetadataRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectMetadataParseTest01", DetectMetadataParseTest01); UtRegisterTest("DetectMetadataParseTest02", DetectMetadataParseTest02); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-modbus.c b/src/detect-modbus.c index f064d67308..3fb52819d4 100644 --- a/src/detect-modbus.c +++ b/src/detect-modbus.c @@ -77,8 +77,9 @@ static DetectParseRegex access_parse_regex; static int g_modbus_buffer_id = 0; - +#ifdef UNITTESTS void DetectModbusRegisterTests(void); +#endif /** \internal * @@ -555,8 +556,9 @@ void DetectModbusRegister(void) sigmatch_table[DETECT_AL_MODBUS].Match = NULL; sigmatch_table[DETECT_AL_MODBUS].Setup = DetectModbusSetup; sigmatch_table[DETECT_AL_MODBUS].Free = DetectModbusFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_MODBUS].RegisterTests = DetectModbusRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX_UNIT_ID, &unit_id_parse_regex); DetectSetupParseRegexes(PARSE_REGEX_FUNCTION, &function_parse_regex); DetectSetupParseRegexes(PARSE_REGEX_ACCESS, &access_parse_regex); @@ -974,14 +976,12 @@ static int DetectModbusTest13(void) DetectEngineCtxFree(de_ctx); PASS; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for DetectModbus */ void DetectModbusRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectModbusTest01 - Testing function", DetectModbusTest01); UtRegisterTest("DetectModbusTest02 - Testing function and subfunction", @@ -1008,5 +1008,5 @@ void DetectModbusRegisterTests(void) DetectModbusTest12); UtRegisterTest("DetectModbusTest13 - Testing a range of unit_id", DetectModbusTest13); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-msg.c b/src/detect-msg.c index a8b9ac1174..cf8cb7f378 100644 --- a/src/detect-msg.c +++ b/src/detect-msg.c @@ -35,7 +35,9 @@ #include "detect-msg.h" static int DetectMsgSetup (DetectEngineCtx *, Signature *, const char *); -void DetectMsgRegisterTests(void); +#ifdef UNITTESTS +static void DetectMsgRegisterTests(void); +#endif void DetectMsgRegister (void) { @@ -45,7 +47,9 @@ void DetectMsgRegister (void) sigmatch_table[DETECT_MSG].Match = NULL; sigmatch_table[DETECT_MSG].Setup = DetectMsgSetup; sigmatch_table[DETECT_MSG].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_MSG].RegisterTests = DetectMsgRegisterTests; +#endif sigmatch_table[DETECT_MSG].flags = SIGMATCH_QUOTES_MANDATORY; } @@ -206,17 +210,13 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectMsg */ void DetectMsgRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectMsgParseTest01", DetectMsgParseTest01); UtRegisterTest("DetectMsgParseTest02", DetectMsgParseTest02); UtRegisterTest("DetectMsgParseTest03", DetectMsgParseTest03); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-nfs-procedure.c b/src/detect-nfs-procedure.c index 81c5476b13..b73c331238 100644 --- a/src/detect-nfs-procedure.c +++ b/src/detect-nfs-procedure.c @@ -71,7 +71,9 @@ typedef struct DetectNfsProcedureData_ { static DetectNfsProcedureData *DetectNfsProcedureParse (const char *); static int DetectNfsProcedureSetup (DetectEngineCtx *, Signature *s, const char *str); static void DetectNfsProcedureFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectNfsProcedureRegisterTests(void); +#endif static int g_nfs_request_buffer_id = 0; static int DetectEngineInspectNfsRequestGeneric(ThreadVars *tv, @@ -96,8 +98,9 @@ void DetectNfsProcedureRegister (void) sigmatch_table[DETECT_AL_NFS_PROCEDURE].AppLayerTxMatch = DetectNfsProcedureMatch; sigmatch_table[DETECT_AL_NFS_PROCEDURE].Setup = DetectNfsProcedureSetup; sigmatch_table[DETECT_AL_NFS_PROCEDURE].Free = DetectNfsProcedureFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_NFS_PROCEDURE].RegisterTests = DetectNfsProcedureRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); @@ -608,14 +611,11 @@ static int ValidityTestParse15 (void) PASS; } -#endif /* UNITTESTS */ - /** * \brief Register unit tests for nfs_procedure. */ void DetectNfsProcedureRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("ValidityTestParse01", ValidityTestParse01); UtRegisterTest("ValidityTestParse02", ValidityTestParse02); UtRegisterTest("ValidityTestParse03", ValidityTestParse03); @@ -631,5 +631,5 @@ void DetectNfsProcedureRegisterTests(void) UtRegisterTest("ValidityTestParse13", ValidityTestParse13); UtRegisterTest("ValidityTestParse14", ValidityTestParse14); UtRegisterTest("ValidityTestParse15", ValidityTestParse15); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-nfs-version.c b/src/detect-nfs-version.c index 570cbabd7e..2f8ef69575 100644 --- a/src/detect-nfs-version.c +++ b/src/detect-nfs-version.c @@ -71,7 +71,9 @@ typedef struct DetectNfsVersionData_ { static DetectNfsVersionData *DetectNfsVersionParse (const char *); static int DetectNfsVersionSetup (DetectEngineCtx *, Signature *s, const char *str); static void DetectNfsVersionFree(DetectEngineCtx *de_ctx, void *); +#ifdef UNITTESTS static void DetectNfsVersionRegisterTests(void); +#endif static int g_nfs_request_buffer_id = 0; static int DetectEngineInspectNfsRequestGeneric(ThreadVars *tv, @@ -96,8 +98,9 @@ void DetectNfsVersionRegister (void) sigmatch_table[DETECT_AL_NFS_VERSION].AppLayerTxMatch = DetectNfsVersionMatch; sigmatch_table[DETECT_AL_NFS_VERSION].Setup = DetectNfsVersionSetup; sigmatch_table[DETECT_AL_NFS_VERSION].Free = DetectNfsVersionFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_NFS_VERSION].RegisterTests = DetectNfsVersionRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); DetectAppLayerInspectEngineRegister("nfs_request", @@ -595,14 +598,11 @@ static int ValidityTestParse15 (void) PASS; } -#endif /* UNITTESTS */ - /** * \brief Register unit tests for nfs_procedure. */ void DetectNfsVersionRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("ValidityTestParse01", ValidityTestParse01); UtRegisterTest("ValidityTestParse02", ValidityTestParse02); UtRegisterTest("ValidityTestParse03", ValidityTestParse03); @@ -618,5 +618,5 @@ void DetectNfsVersionRegisterTests(void) UtRegisterTest("ValidityTestParse13", ValidityTestParse13); UtRegisterTest("ValidityTestParse14", ValidityTestParse14); UtRegisterTest("ValidityTestParse15", ValidityTestParse15); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-noalert.c b/src/detect-noalert.c index 5625af79ab..0a89163e45 100644 --- a/src/detect-noalert.c +++ b/src/detect-noalert.c @@ -35,11 +35,7 @@ void DetectNoalertRegister (void) sigmatch_table[DETECT_NOALERT].name = "noalert"; sigmatch_table[DETECT_NOALERT].desc = "no alert will be generated by the rule"; sigmatch_table[DETECT_NOALERT].url = "/rules/flow-keywords.html"; - sigmatch_table[DETECT_NOALERT].Match = NULL; sigmatch_table[DETECT_NOALERT].Setup = DetectNoalertSetup; - sigmatch_table[DETECT_NOALERT].Free = NULL; - sigmatch_table[DETECT_NOALERT].RegisterTests = NULL; - sigmatch_table[DETECT_NOALERT].flags |= SIGMATCH_NOOPT; } diff --git a/src/detect-nocase.c b/src/detect-nocase.c index fe094c0f5b..60f7330597 100644 --- a/src/detect-nocase.c +++ b/src/detect-nocase.c @@ -40,11 +40,7 @@ void DetectNocaseRegister(void) sigmatch_table[DETECT_NOCASE].name = "nocase"; sigmatch_table[DETECT_NOCASE].desc = "modify content match to be case insensitive"; sigmatch_table[DETECT_NOCASE].url = "/rules/payload-keywords.html#nocase"; - sigmatch_table[DETECT_NOCASE].Match = NULL; sigmatch_table[DETECT_NOCASE].Setup = DetectNocaseSetup; - sigmatch_table[DETECT_NOCASE].Free = NULL; - sigmatch_table[DETECT_NOCASE].RegisterTests = NULL; - sigmatch_table[DETECT_NOCASE].flags |= SIGMATCH_NOOPT; } diff --git a/src/detect-offset.c b/src/detect-offset.c index acf0913d56..67dbb5ec96 100644 --- a/src/detect-offset.c +++ b/src/detect-offset.c @@ -48,10 +48,7 @@ void DetectOffsetRegister (void) sigmatch_table[DETECT_OFFSET].name = "offset"; sigmatch_table[DETECT_OFFSET].desc = "designate from which byte in the payload will be checked to find a match"; sigmatch_table[DETECT_OFFSET].url = "/rules/payload-keywords.html#offset"; - sigmatch_table[DETECT_OFFSET].Match = NULL; sigmatch_table[DETECT_OFFSET].Setup = DetectOffsetSetup; - sigmatch_table[DETECT_OFFSET].Free = NULL; - sigmatch_table[DETECT_OFFSET].RegisterTests = NULL; } int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, const char *offsetstr) diff --git a/src/detect-pcre.c b/src/detect-pcre.c index 0668814b80..c6588ba6ab 100644 --- a/src/detect-pcre.c +++ b/src/detect-pcre.c @@ -108,7 +108,9 @@ static inline int DetectPcreExec(DetectEngineThreadCtx *det_ctx, DetectPcreData static int DetectPcreSetup (DetectEngineCtx *, Signature *, const char *); static void DetectPcreFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS static void DetectPcreRegisterTests(void); +#endif void DetectPcreRegister (void) { @@ -118,7 +120,9 @@ void DetectPcreRegister (void) sigmatch_table[DETECT_PCRE].Match = NULL; sigmatch_table[DETECT_PCRE].Setup = DetectPcreSetup; sigmatch_table[DETECT_PCRE].Free = DetectPcreFree; +#ifdef UNITTESTS sigmatch_table[DETECT_PCRE].RegisterTests = DetectPcreRegisterTests; +#endif sigmatch_table[DETECT_PCRE].flags = (SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION); intmax_t val = 0; @@ -3560,14 +3564,11 @@ static int DetectPcreParseCaptureTest(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectPcre */ static void DetectPcreRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ g_file_data_buffer_id = DetectBufferTypeGetByName("file_data"); g_http_header_buffer_id = DetectBufferTypeGetByName("http_header"); g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data"); @@ -3649,6 +3650,5 @@ static void DetectPcreRegisterTests(void) UtRegisterTest("DetectPcreParseHttpHost", DetectPcreParseHttpHost); UtRegisterTest("DetectPcreParseCaptureTest", DetectPcreParseCaptureTest); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-pkt-data.c b/src/detect-pkt-data.c index 792597e9d8..730d59d2f9 100644 --- a/src/detect-pkt-data.c +++ b/src/detect-pkt-data.c @@ -44,7 +44,9 @@ #include "util-unittest-helper.h" static int DetectPktDataSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectPktDataTestRegister(void); +#endif /** * \brief Registration function for keyword: file_data @@ -53,7 +55,9 @@ void DetectPktDataRegister(void) { sigmatch_table[DETECT_PKT_DATA].name = "pkt_data"; sigmatch_table[DETECT_PKT_DATA].Setup = DetectPktDataSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_PKT_DATA].RegisterTests = DetectPktDataTestRegister; +#endif sigmatch_table[DETECT_PKT_DATA].flags = SIGMATCH_NOOPT; } @@ -123,15 +127,11 @@ static int DetectPktDataTest02(void) DetectEngineCtxFree(de_ctx); PASS; } -#endif static void DetectPktDataTestRegister(void) { -#ifdef UNITTESTS g_file_data_buffer_id = DetectBufferTypeGetByName("file_data"); - UtRegisterTest("DetectPktDataTest01", DetectPktDataTest01); UtRegisterTest("DetectPktDataTest02", DetectPktDataTest02); -#endif } - +#endif \ No newline at end of file diff --git a/src/detect-pktvar.c b/src/detect-pktvar.c index c5e28665f2..7ddf6938e3 100644 --- a/src/detect-pktvar.c +++ b/src/detect-pktvar.c @@ -50,7 +50,6 @@ void DetectPktvarRegister (void) sigmatch_table[DETECT_PKTVAR].Match = DetectPktvarMatch; sigmatch_table[DETECT_PKTVAR].Setup = DetectPktvarSetup; sigmatch_table[DETECT_PKTVAR].Free = DetectPktvarFree; - sigmatch_table[DETECT_PKTVAR].RegisterTests = NULL; DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } diff --git a/src/detect-prefilter.c b/src/detect-prefilter.c index b311b19153..4aab7c1655 100644 --- a/src/detect-prefilter.c +++ b/src/detect-prefilter.c @@ -39,11 +39,7 @@ void DetectPrefilterRegister(void) sigmatch_table[DETECT_PREFILTER].name = "prefilter"; sigmatch_table[DETECT_PREFILTER].desc = "force a condition to be used as prefilter"; sigmatch_table[DETECT_PREFILTER].url = "/rules/prefilter-keywords.html#prefilter"; - sigmatch_table[DETECT_PREFILTER].Match = NULL; sigmatch_table[DETECT_PREFILTER].Setup = DetectPrefilterSetup; - sigmatch_table[DETECT_PREFILTER].Free = NULL; - sigmatch_table[DETECT_PREFILTER].RegisterTests = NULL; - sigmatch_table[DETECT_PREFILTER].flags |= SIGMATCH_NOOPT; } diff --git a/src/detect-priority.c b/src/detect-priority.c index c39b880e11..6860b4ea97 100644 --- a/src/detect-priority.c +++ b/src/detect-priority.c @@ -39,7 +39,9 @@ static DetectParseRegex parse_regex; static int DetectPrioritySetup (DetectEngineCtx *, Signature *, const char *); -void SCPriorityRegisterTests(void); +#ifdef UNITTESTS +static void PriorityRegisterTests(void); +#endif /** * \brief Registers the handler functions for the "priority" keyword @@ -50,8 +52,9 @@ void DetectPriorityRegister (void) sigmatch_table[DETECT_PRIORITY].desc = "rules with a higher priority will be examined first"; sigmatch_table[DETECT_PRIORITY].url = "/rules/meta.html#priority"; sigmatch_table[DETECT_PRIORITY].Setup = DetectPrioritySetup; - sigmatch_table[DETECT_PRIORITY].RegisterTests = SCPriorityRegisterTests; - +#ifdef UNITTESTS + sigmatch_table[DETECT_PRIORITY].RegisterTests = PriorityRegisterTests; +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -163,15 +166,13 @@ static int DetectPriorityTest02(void) DetectEngineCtxFree(de_ctx); PASS; } -#endif /* UNITTESTS */ /** * \brief This function registers unit tests for Classification Config API. */ -void SCPriorityRegisterTests(void) +static void PriorityRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectPriorityTest01", DetectPriorityTest01); UtRegisterTest("DetectPriorityTest02", DetectPriorityTest02); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-replace.c b/src/detect-replace.c index 3e36fee688..a7384475a0 100644 --- a/src/detect-replace.c +++ b/src/detect-replace.c @@ -60,8 +60,9 @@ extern int run_mode; #include "util-profiling.h" static int DetectReplaceSetup(DetectEngineCtx *, Signature *, const char *); -void DetectReplaceRegisterTests(void); - +#ifdef UNITTESTS +static void DetectReplaceRegisterTests(void); +#endif static int DetectReplacePostMatch(DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s, const SigMatchCtx *ctx); @@ -72,8 +73,9 @@ void DetectReplaceRegister (void) sigmatch_table[DETECT_REPLACE].url = "/rules/payload-keywords.html#replace"; sigmatch_table[DETECT_REPLACE].Match = DetectReplacePostMatch; sigmatch_table[DETECT_REPLACE].Setup = DetectReplaceSetup; - sigmatch_table[DETECT_REPLACE].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_REPLACE].RegisterTests = DetectReplaceRegisterTests; +#endif sigmatch_table[DETECT_REPLACE].flags = (SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION); } @@ -830,16 +832,11 @@ static int DetectReplaceParseTest07(void) return result; } - - -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectContent */ void DetectReplaceRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ /* matching */ UtRegisterTest("DetectReplaceMatchTest01", DetectReplaceMatchTest01); UtRegisterTest("DetectReplaceMatchTest02", DetectReplaceMatchTest02); @@ -864,5 +861,5 @@ void DetectReplaceRegisterTests(void) UtRegisterTest("DetectReplaceParseTest05", DetectReplaceParseTest05); UtRegisterTest("DetectReplaceParseTest06", DetectReplaceParseTest06); UtRegisterTest("DetectReplaceParseTest07", DetectReplaceParseTest07); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-rev.c b/src/detect-rev.c index 8f5da5cf41..fb3def8d10 100644 --- a/src/detect-rev.c +++ b/src/detect-rev.c @@ -36,10 +36,7 @@ void DetectRevRegister (void) sigmatch_table[DETECT_REV].name = "rev"; sigmatch_table[DETECT_REV].desc = "set version of the rule"; sigmatch_table[DETECT_REV].url = "/rules/meta.html#rev-revision"; - sigmatch_table[DETECT_REV].Match = NULL; sigmatch_table[DETECT_REV].Setup = DetectRevSetup; - sigmatch_table[DETECT_REV].Free = NULL; - sigmatch_table[DETECT_REV].RegisterTests = NULL; } static int DetectRevSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) @@ -71,5 +68,4 @@ static int DetectRevSetup (DetectEngineCtx *de_ctx, Signature *s, const char *ra error: return -1; -} - +} \ No newline at end of file diff --git a/src/detect-rfb-secresult.c b/src/detect-rfb-secresult.c index fcf2857427..611e5ecca5 100644 --- a/src/detect-rfb-secresult.c +++ b/src/detect-rfb-secresult.c @@ -42,7 +42,9 @@ static int DetectRfbSecresultMatch(DetectEngineThreadCtx *det_ctx, void *txv, const Signature *s, const SigMatchCtx *ctx); static int DetectRfbSecresultSetup (DetectEngineCtx *, Signature *, const char *); -void RfbSecresultRegisterTests(void); +#ifdef UNITTESTS +static void RfbSecresultRegisterTests(void); +#endif void DetectRfbSecresultFree(DetectEngineCtx *, void *); static int DetectEngineInspectRfbSecresultGeneric(ThreadVars *tv, @@ -66,8 +68,9 @@ void DetectRfbSecresultRegister (void) sigmatch_table[DETECT_AL_RFB_SECRESULT].AppLayerTxMatch = DetectRfbSecresultMatch; sigmatch_table[DETECT_AL_RFB_SECRESULT].Setup = DetectRfbSecresultSetup; sigmatch_table[DETECT_AL_RFB_SECRESULT].Free = DetectRfbSecresultFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_RFB_SECRESULT].RegisterTests = RfbSecresultRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); DetectAppLayerInspectEngineRegister("rfb.secresult", @@ -300,15 +303,12 @@ static int RfbSecresultTestParse02 (void) return 1; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for RfbSecresult */ void RfbSecresultRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("RfbSecresultTestParse01", RfbSecresultTestParse01); UtRegisterTest("RfbSecresultTestParse02", RfbSecresultTestParse02); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-rpc.c b/src/detect-rpc.c index 5d1226c895..35e83ca7d2 100644 --- a/src/detect-rpc.c +++ b/src/detect-rpc.c @@ -50,7 +50,9 @@ static DetectParseRegex parse_regex; static int DetectRpcMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectRpcSetup (DetectEngineCtx *, Signature *, const char *); -void DetectRpcRegisterTests(void); +#ifdef UNITTESTS +static void DetectRpcRegisterTests(void); +#endif void DetectRpcFree(DetectEngineCtx *, void *); /** @@ -64,8 +66,9 @@ void DetectRpcRegister (void) sigmatch_table[DETECT_RPC].Match = DetectRpcMatch; sigmatch_table[DETECT_RPC].Setup = DetectRpcSetup; sigmatch_table[DETECT_RPC].Free = DetectRpcFree; +#ifdef UNITTESTS sigmatch_table[DETECT_RPC].RegisterTests = DetectRpcRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -569,19 +572,17 @@ cleanup: end: return result; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for DetectRpc */ -void DetectRpcRegisterTests(void) +static void DetectRpcRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectRpcTestParse01", DetectRpcTestParse01); UtRegisterTest("DetectRpcTestParse02", DetectRpcTestParse02); UtRegisterTest("DetectRpcTestParse03", DetectRpcTestParse03); UtRegisterTest("DetectRpcTestParse04", DetectRpcTestParse04); UtRegisterTest("DetectRpcTestParse05", DetectRpcTestParse05); UtRegisterTest("DetectRpcTestSig01", DetectRpcTestSig01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-sameip.c b/src/detect-sameip.c index ca83429933..71aab90a20 100644 --- a/src/detect-sameip.c +++ b/src/detect-sameip.c @@ -40,7 +40,9 @@ static int DetectSameipMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectSameipSetup(DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectSameipRegisterTests(void); +#endif /** * \brief Registration function for sameip: keyword @@ -53,8 +55,9 @@ void DetectSameipRegister(void) sigmatch_table[DETECT_SAMEIP].url = "/rules/header-keywords.html#sameip"; sigmatch_table[DETECT_SAMEIP].Match = DetectSameipMatch; sigmatch_table[DETECT_SAMEIP].Setup = DetectSameipSetup; - sigmatch_table[DETECT_SAMEIP].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_SAMEIP].RegisterTests = DetectSameipRegisterTests; +#endif sigmatch_table[DETECT_SAMEIP].flags = SIGMATCH_NOOPT; } @@ -181,15 +184,12 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \internal * \brief This function registers unit tests for DetectSameip */ static void DetectSameipRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectSameipSigTest01", DetectSameipSigTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-sid.c b/src/detect-sid.c index 94dedc8f0a..2c0323b594 100644 --- a/src/detect-sid.c +++ b/src/detect-sid.c @@ -33,7 +33,9 @@ #include "util-unittest.h" static int DetectSidSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectSidRegisterTests(void); +#endif void DetectSidRegister (void) { @@ -42,8 +44,9 @@ void DetectSidRegister (void) sigmatch_table[DETECT_SID].url = "/rules/meta.html#sid-signature-id"; sigmatch_table[DETECT_SID].Match = NULL; sigmatch_table[DETECT_SID].Setup = DetectSidSetup; - sigmatch_table[DETECT_SID].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_SID].RegisterTests = DetectSidRegisterTests; +#endif } static int DetectSidSetup (DetectEngineCtx *de_ctx, Signature *s, const char *sidstr) @@ -139,16 +142,13 @@ end: return result; } -#endif - /** * \brief Register DetectSid unit tests. */ static void DetectSidRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("SidTestParse01", SidTestParse01); UtRegisterTest("SidTestParse02", SidTestParse02); UtRegisterTest("SidTestParse03", SidTestParse03); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-ssh-hassh-server-string.c b/src/detect-ssh-hassh-server-string.c index 583d08b90c..6c6b0b10ee 100644 --- a/src/detect-ssh-hassh-server-string.c +++ b/src/detect-ssh-hassh-server-string.c @@ -126,7 +126,6 @@ void DetectSshHasshServerStringRegister(void) sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].name = KEYWORD_NAME; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].alias = KEYWORD_ALIAS; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].desc = BUFFER_NAME " sticky buffer"; - sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].RegisterTests = NULL; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].url = "/rules/" KEYWORD_DOC; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].Setup = DetectSshHasshServerStringSetup; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].flags |= SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_NOOPT; diff --git a/src/detect-ssh-hassh-server.c b/src/detect-ssh-hassh-server.c index 07d171e777..3978dc3a0f 100644 --- a/src/detect-ssh-hassh-server.c +++ b/src/detect-ssh-hassh-server.c @@ -193,7 +193,6 @@ void DetectSshHasshServerRegister(void) sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].name = KEYWORD_NAME; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].alias = KEYWORD_ALIAS; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].desc = BUFFER_NAME " sticky buffer"; - sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].RegisterTests = NULL; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].url = "/rules/" KEYWORD_DOC; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].Setup = DetectSshHasshServerSetup; sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].flags |= SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_NOOPT; diff --git a/src/detect-ssh-hassh-string.c b/src/detect-ssh-hassh-string.c index 5ab6605d82..5c34371693 100644 --- a/src/detect-ssh-hassh-string.c +++ b/src/detect-ssh-hassh-string.c @@ -126,7 +126,6 @@ void DetectSshHasshStringRegister(void) sigmatch_table[DETECT_AL_SSH_HASSH_STRING].name = KEYWORD_NAME; sigmatch_table[DETECT_AL_SSH_HASSH_STRING].alias = KEYWORD_ALIAS; sigmatch_table[DETECT_AL_SSH_HASSH_STRING].desc = BUFFER_NAME " sticky buffer"; - sigmatch_table[DETECT_AL_SSH_HASSH_STRING].RegisterTests = NULL; sigmatch_table[DETECT_AL_SSH_HASSH_STRING].url = "/rules/" KEYWORD_DOC; sigmatch_table[DETECT_AL_SSH_HASSH_STRING].Setup = DetectSshHasshStringSetup; sigmatch_table[DETECT_AL_SSH_HASSH_STRING].flags |= SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_NOOPT; diff --git a/src/detect-ssh-hassh.c b/src/detect-ssh-hassh.c index 8d482e7543..8cd4b5749d 100644 --- a/src/detect-ssh-hassh.c +++ b/src/detect-ssh-hassh.c @@ -193,7 +193,6 @@ void DetectSshHasshRegister(void) sigmatch_table[DETECT_AL_SSH_HASSH].name = KEYWORD_NAME; sigmatch_table[DETECT_AL_SSH_HASSH].alias = KEYWORD_ALIAS; sigmatch_table[DETECT_AL_SSH_HASSH].desc = BUFFER_NAME " sticky buffer"; - sigmatch_table[DETECT_AL_SSH_HASSH].RegisterTests = NULL; sigmatch_table[DETECT_AL_SSH_HASSH].url = "/rules/" KEYWORD_DOC; sigmatch_table[DETECT_AL_SSH_HASSH].Setup = DetectSshHasshSetup; sigmatch_table[DETECT_AL_SSH_HASSH].flags |= SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_NOOPT; diff --git a/src/detect-ssh-proto-version.c b/src/detect-ssh-proto-version.c index 30a503ff2c..23c6b87e4d 100644 --- a/src/detect-ssh-proto-version.c +++ b/src/detect-ssh-proto-version.c @@ -66,7 +66,9 @@ static int DetectSshVersionMatch (DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); static int DetectSshVersionSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectSshVersionRegisterTests(void); +#endif static void DetectSshVersionFree(DetectEngineCtx *, void *); static int g_ssh_banner_list_id = 0; @@ -81,7 +83,9 @@ void DetectSshVersionRegister(void) sigmatch_table[DETECT_AL_SSH_PROTOVERSION].AppLayerTxMatch = DetectSshVersionMatch; sigmatch_table[DETECT_AL_SSH_PROTOVERSION].Setup = DetectSshVersionSetup; sigmatch_table[DETECT_AL_SSH_PROTOVERSION].Free = DetectSshVersionFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_SSH_PROTOVERSION].RegisterTests = DetectSshVersionRegisterTests; +#endif sigmatch_table[DETECT_AL_SSH_PROTOVERSION].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_INFO_DEPRECATED; sigmatch_table[DETECT_AL_SSH_PROTOVERSION].alternative = DETECT_AL_SSH_PROTOCOL; @@ -566,14 +570,11 @@ static int DetectSshVersionTestDetect03(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectSshVersion */ -void DetectSshVersionRegisterTests(void) +static void DetectSshVersionRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectSshVersionTestParse01", DetectSshVersionTestParse01); UtRegisterTest("DetectSshVersionTestParse02", DetectSshVersionTestParse02); UtRegisterTest("DetectSshVersionTestParse03", DetectSshVersionTestParse03); @@ -583,6 +584,5 @@ void DetectSshVersionRegisterTests(void) DetectSshVersionTestDetect02); UtRegisterTest("DetectSshVersionTestDetect03", DetectSshVersionTestDetect03); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-ssh-software-version.c b/src/detect-ssh-software-version.c index e24a241910..bebe2b8b98 100644 --- a/src/detect-ssh-software-version.c +++ b/src/detect-ssh-software-version.c @@ -70,7 +70,9 @@ static int DetectSshSoftwareVersionMatch (DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); static int DetectSshSoftwareVersionSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectSshSoftwareVersionRegisterTests(void); +#endif static void DetectSshSoftwareVersionFree(DetectEngineCtx *de_ctx, void *); static int g_ssh_banner_list_id = 0; @@ -95,7 +97,9 @@ void DetectSshSoftwareVersionRegister(void) sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].AppLayerTxMatch = DetectSshSoftwareVersionMatch; sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].Setup = DetectSshSoftwareVersionSetup; sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].Free = DetectSshSoftwareVersionFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].RegisterTests = DetectSshSoftwareVersionRegisterTests; +#endif sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_INFO_DEPRECATED; sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].alternative = DETECT_AL_SSH_SOFTWARE; @@ -551,14 +555,11 @@ static int DetectSshSoftwareVersionTestDetect03(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectSshSoftwareVersion */ static void DetectSshSoftwareVersionRegisterTests(void) { -#ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectSshSoftwareVersionTestParse01", DetectSshSoftwareVersionTestParse01); UtRegisterTest("DetectSshSoftwareVersionTestParse02", @@ -571,6 +572,5 @@ static void DetectSshSoftwareVersionRegisterTests(void) DetectSshSoftwareVersionTestDetect02); UtRegisterTest("DetectSshSoftwareVersionTestDetect03", DetectSshSoftwareVersionTestDetect03); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-stream_size.c b/src/detect-stream_size.c index f8b46c4450..68e7561008 100644 --- a/src/detect-stream_size.c +++ b/src/detect-stream_size.c @@ -48,7 +48,9 @@ static int DetectStreamSizeMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectStreamSizeSetup (DetectEngineCtx *, Signature *, const char *); void DetectStreamSizeFree(DetectEngineCtx *de_ctx, void *); -void DetectStreamSizeRegisterTests(void); +#ifdef UNITTESTS +static void DetectStreamSizeRegisterTests(void); +#endif /** * \brief Registration function for stream_size: keyword @@ -62,8 +64,9 @@ void DetectStreamSizeRegister(void) sigmatch_table[DETECT_STREAM_SIZE].Match = DetectStreamSizeMatch; sigmatch_table[DETECT_STREAM_SIZE].Setup = DetectStreamSizeSetup; sigmatch_table[DETECT_STREAM_SIZE].Free = DetectStreamSizeFree; +#ifdef UNITTESTS sigmatch_table[DETECT_STREAM_SIZE].RegisterTests = DetectStreamSizeRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -489,18 +492,15 @@ static int DetectStreamSizeParseTest04 (void) SCFree(p); return result; } -#endif /* UNITTESTS */ /** * \brief this function registers unit tests for DetectStreamSize */ void DetectStreamSizeRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectStreamSizeParseTest01", DetectStreamSizeParseTest01); UtRegisterTest("DetectStreamSizeParseTest02", DetectStreamSizeParseTest02); UtRegisterTest("DetectStreamSizeParseTest03", DetectStreamSizeParseTest03); UtRegisterTest("DetectStreamSizeParseTest04", DetectStreamSizeParseTest04); -#endif /* UNITTESTS */ } - +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-tag.c b/src/detect-tag.c index 633b70d9b9..225fa567ce 100644 --- a/src/detect-tag.c +++ b/src/detect-tag.c @@ -59,7 +59,9 @@ static DetectParseRegex parse_regex; static int DetectTagMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectTagSetup(DetectEngineCtx *, Signature *, const char *); -void DetectTagRegisterTests(void); +#ifdef UNITTESTS +static void DetectTagRegisterTests(void); +#endif void DetectTagDataFree(DetectEngineCtx *, void *); /** @@ -71,7 +73,9 @@ void DetectTagRegister(void) sigmatch_table[DETECT_TAG].Match = DetectTagMatch; sigmatch_table[DETECT_TAG].Setup = DetectTagSetup; sigmatch_table[DETECT_TAG].Free = DetectTagDataFree; +#ifdef UNITTESTS sigmatch_table[DETECT_TAG].RegisterTests = DetectTagRegisterTests; +#endif sigmatch_table[DETECT_TAG].flags |= SIGMATCH_IPONLY_COMPAT; DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); @@ -441,14 +445,11 @@ static int DetectTagTestParse05(void) return result; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectTag */ void DetectTagRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTagTestParse01", DetectTagTestParse01); UtRegisterTest("DetectTagTestParse02", DetectTagTestParse02); UtRegisterTest("DetectTagTestParse03", DetectTagTestParse03); @@ -456,5 +457,5 @@ void DetectTagRegisterTests(void) UtRegisterTest("DetectTagTestParse05", DetectTagTestParse05); DetectEngineTagRegisterTests(); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-target.c b/src/detect-target.c index 52680a351b..62be7fb1b6 100644 --- a/src/detect-target.c +++ b/src/detect-target.c @@ -40,7 +40,9 @@ static DetectParseRegex parse_regex; /* Prototypes of functions registered in DetectTargetRegister below */ static int DetectTargetSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectTargetRegisterTests (void); +#endif /** * \brief Registration function for target keyword @@ -62,8 +64,9 @@ void DetectTargetRegister(void) { * shutdown, but also during rule reloads. */ sigmatch_table[DETECT_TARGET].Free = NULL; /* registers unittests into the system */ +#ifdef UNITTESTS sigmatch_table[DETECT_TARGET].RegisterTests = DetectTargetRegisterTests; - +#endif /* set up the PCRE for keyword parsing */ DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -151,14 +154,12 @@ static int DetectTargetSignatureTest01(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectTarget */ -void DetectTargetRegisterTests(void) { -#ifdef UNITTESTS +static void DetectTargetRegisterTests(void) +{ UtRegisterTest("DetectTargetSignatureTest01", DetectTargetSignatureTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-tcp-ack.c b/src/detect-tcp-ack.c index 31680b1543..ebfbdad5f5 100644 --- a/src/detect-tcp-ack.c +++ b/src/detect-tcp-ack.c @@ -46,7 +46,9 @@ static int DetectAckSetup(DetectEngineCtx *, Signature *, const char *); static int DetectAckMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); +#ifdef UNITTESTS static void DetectAckRegisterTests(void); +#endif static void DetectAckFree(DetectEngineCtx *, void *); static int PrefilterSetupTcpAck(DetectEngineCtx *de_ctx, SigGroupHead *sgh); static bool PrefilterTcpAckIsPrefilterable(const Signature *s); @@ -63,8 +65,9 @@ void DetectAckRegister(void) sigmatch_table[DETECT_ACK].SupportsPrefilter = PrefilterTcpAckIsPrefilterable; sigmatch_table[DETECT_ACK].SetupPrefilter = PrefilterSetupTcpAck; - +#ifdef UNITTESTS sigmatch_table[DETECT_ACK].RegisterTests = DetectAckRegisterTests; +#endif } /** @@ -323,15 +326,12 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \internal * \brief This function registers unit tests for DetectAck */ static void DetectAckRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectAckSigTest01", DetectAckSigTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-tcp-flags.c b/src/detect-tcp-flags.c index c35d1c79a2..62decaaa46 100644 --- a/src/detect-tcp-flags.c +++ b/src/detect-tcp-flags.c @@ -64,6 +64,9 @@ static void DetectFlagsFree(DetectEngineCtx *, void *); static bool PrefilterTcpFlagsIsPrefilterable(const Signature *s); static int PrefilterSetupTcpFlags(DetectEngineCtx *de_ctx, SigGroupHead *sgh); +#ifdef UNITTESTS +static void FlagsRegisterTests(void); +#endif /** * \brief Registration function for flags: keyword @@ -78,8 +81,9 @@ void DetectFlagsRegister (void) sigmatch_table[DETECT_FLAGS].Match = DetectFlagsMatch; sigmatch_table[DETECT_FLAGS].Setup = DetectFlagsSetup; sigmatch_table[DETECT_FLAGS].Free = DetectFlagsFree; +#ifdef UNITTESTS sigmatch_table[DETECT_FLAGS].RegisterTests = FlagsRegisterTests; - +#endif sigmatch_table[DETECT_FLAGS].SupportsPrefilter = PrefilterTcpFlagsIsPrefilterable; sigmatch_table[DETECT_FLAGS].SetupPrefilter = PrefilterSetupTcpFlags; @@ -1395,14 +1399,11 @@ error: return 0; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for Flags */ -void FlagsRegisterTests(void) +static void FlagsRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("FlagsTestParse01", FlagsTestParse01); UtRegisterTest("FlagsTestParse02", FlagsTestParse02); UtRegisterTest("FlagsTestParse03", FlagsTestParse03); @@ -1420,5 +1421,5 @@ void FlagsRegisterTests(void) UtRegisterTest("FlagsTestParse15", FlagsTestParse15); UtRegisterTest("FlagsTestParse16", FlagsTestParse16); UtRegisterTest("FlagsTestParse17", FlagsTestParse17); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-tcp-flags.h b/src/detect-tcp-flags.h index 333ed91021..9b6b24021f 100644 --- a/src/detect-tcp-flags.h +++ b/src/detect-tcp-flags.h @@ -50,12 +50,6 @@ typedef struct DetectFlagsData_ { void DetectFlagsRegister (void); -/** - * This function registers unit tests for Flags - */ - -void FlagsRegisterTests(void); - int DetectFlagsSignatureNeedsSynPackets(const Signature *s); int DetectFlagsSignatureNeedsSynOnlyPackets(const Signature *s); diff --git a/src/detect-tcp-seq.c b/src/detect-tcp-seq.c index f364afd99c..09d075b644 100644 --- a/src/detect-tcp-seq.c +++ b/src/detect-tcp-seq.c @@ -43,7 +43,9 @@ static int DetectSeqSetup(DetectEngineCtx *, Signature *, const char *); static int DetectSeqMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); +#ifdef UNITTESTS static void DetectSeqRegisterTests(void); +#endif static void DetectSeqFree(DetectEngineCtx *, void *); static int PrefilterSetupTcpSeq(DetectEngineCtx *de_ctx, SigGroupHead *sgh); static bool PrefilterTcpSeqIsPrefilterable(const Signature *s); @@ -57,8 +59,9 @@ void DetectSeqRegister(void) sigmatch_table[DETECT_SEQ].Match = DetectSeqMatch; sigmatch_table[DETECT_SEQ].Setup = DetectSeqSetup; sigmatch_table[DETECT_SEQ].Free = DetectSeqFree; +#ifdef UNITTESTS sigmatch_table[DETECT_SEQ].RegisterTests = DetectSeqRegisterTests; - +#endif sigmatch_table[DETECT_SEQ].SupportsPrefilter = PrefilterTcpSeqIsPrefilterable; sigmatch_table[DETECT_SEQ].SetupPrefilter = PrefilterSetupTcpSeq; } @@ -287,16 +290,13 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \internal * \brief This function registers unit tests for DetectSeq */ static void DetectSeqRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectSeqSigTest01", DetectSeqSigTest01); UtRegisterTest("DetectSeqSigTest02", DetectSeqSigTest02); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-tcp-window.c b/src/detect-tcp-window.c index f45bdb8344..da2693fc8e 100644 --- a/src/detect-tcp-window.c +++ b/src/detect-tcp-window.c @@ -49,7 +49,9 @@ static DetectParseRegex parse_regex; static int DetectWindowMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectWindowSetup(DetectEngineCtx *, Signature *, const char *); -void DetectWindowRegisterTests(void); +#ifdef UNITTESTS +static void DetectWindowRegisterTests(void); +#endif void DetectWindowFree(DetectEngineCtx *, void *); /** @@ -64,8 +66,9 @@ void DetectWindowRegister (void) sigmatch_table[DETECT_WINDOW].Match = DetectWindowMatch; sigmatch_table[DETECT_WINDOW].Setup = DetectWindowSetup; sigmatch_table[DETECT_WINDOW].Free = DetectWindowFree; +#ifdef UNITTESTS sigmatch_table[DETECT_WINDOW].RegisterTests = DetectWindowRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); } @@ -327,18 +330,15 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectWindow */ void DetectWindowRegisterTests(void) { - #ifdef UNITTESTS /* UNITTESTS */ UtRegisterTest("DetectWindowTestParse01", DetectWindowTestParse01); UtRegisterTest("DetectWindowTestParse02", DetectWindowTestParse02); UtRegisterTest("DetectWindowTestParse03", DetectWindowTestParse03); UtRegisterTest("DetectWindowTestParse04", DetectWindowTestParse04); UtRegisterTest("DetectWindowTestPacket01", DetectWindowTestPacket01); - #endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-template-rust-buffer.c b/src/detect-template-rust-buffer.c index 2979530421..d2615dea33 100644 --- a/src/detect-template-rust-buffer.c +++ b/src/detect-template-rust-buffer.c @@ -47,7 +47,9 @@ static int DetectEngineInspectTemplateRustBuffer(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, const SigMatchData *smd, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id); +#ifdef UNITTESTS static void DetectTemplateRustBufferRegisterTests(void); +#endif static int g_template_rust_id = 0; void DetectTemplateRustBufferRegister(void) @@ -63,9 +65,10 @@ void DetectTemplateRustBufferRegister(void) "Template content modififier to match on the template buffers"; sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].Setup = DetectTemplateRustBufferSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].RegisterTests = DetectTemplateRustBufferRegisterTests; - +#endif sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].flags |= SIGMATCH_NOOPT; /* register inspect engines */ @@ -205,12 +208,9 @@ static int DetectTemplateRustBufferTest(void) PASS; } -#endif - static void DetectTemplateRustBufferRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTemplateRustBufferTest", DetectTemplateRustBufferTest); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/detect-threshold.c b/src/detect-threshold.c index 1398fb7d01..612fb56e45 100644 --- a/src/detect-threshold.c +++ b/src/detect-threshold.c @@ -67,6 +67,9 @@ static int DetectThresholdMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectThresholdSetup(DetectEngineCtx *, Signature *, const char *); static void DetectThresholdFree(DetectEngineCtx *, void *); +#ifdef UNITTESTS +static void ThresholdRegisterTests(void); +#endif /** * \brief Registration function for threshold: keyword @@ -80,7 +83,9 @@ void DetectThresholdRegister(void) sigmatch_table[DETECT_THRESHOLD].Match = DetectThresholdMatch; sigmatch_table[DETECT_THRESHOLD].Setup = DetectThresholdSetup; sigmatch_table[DETECT_THRESHOLD].Free = DetectThresholdFree; +#ifdef UNITTESTS sigmatch_table[DETECT_THRESHOLD].RegisterTests = ThresholdRegisterTests; +#endif /* this is compatible to ip-only signatures */ sigmatch_table[DETECT_THRESHOLD].flags |= SIGMATCH_IPONLY_COMPAT; @@ -1673,11 +1678,8 @@ static int DetectThresholdTestSig14(void) PASS; } -#endif /* UNITTESTS */ - -void ThresholdRegisterTests(void) +static void ThresholdRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("ThresholdTestParse01", ThresholdTestParse01); UtRegisterTest("ThresholdTestParse02", ThresholdTestParse02); UtRegisterTest("ThresholdTestParse03", ThresholdTestParse03); @@ -1700,8 +1702,8 @@ void ThresholdRegisterTests(void) UtRegisterTest("DetectThresholdTestSig12", DetectThresholdTestSig12); UtRegisterTest("DetectThresholdTestSig13", DetectThresholdTestSig13); UtRegisterTest("DetectThresholdTestSig14", DetectThresholdTestSig14); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ /** * @} diff --git a/src/detect-threshold.h b/src/detect-threshold.h index 05ebe2e76a..616e48ab2c 100644 --- a/src/detect-threshold.h +++ b/src/detect-threshold.h @@ -86,10 +86,4 @@ typedef struct DetectThresholdEntry_ { void DetectThresholdRegister(void); -/** - * This function registers unit tests for Threshold - */ - -void ThresholdRegisterTests(void); - #endif /*__DETECT_THRESHOLD_H__ */ diff --git a/src/detect-tls.c b/src/detect-tls.c index 0ce262f89b..3465ca07d4 100644 --- a/src/detect-tls.c +++ b/src/detect-tls.c @@ -75,14 +75,12 @@ static int DetectTlsSubjectMatch (DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); static int DetectTlsSubjectSetup (DetectEngineCtx *, Signature *, const char *); -static void DetectTlsSubjectRegisterTests(void); static void DetectTlsSubjectFree(DetectEngineCtx *, void *); static int DetectTlsIssuerDNMatch (DetectEngineThreadCtx *, Flow *, uint8_t, void *, void *, const Signature *, const SigMatchCtx *); static int DetectTlsIssuerDNSetup (DetectEngineCtx *, Signature *, const char *); -static void DetectTlsIssuerDNRegisterTests(void); static void DetectTlsIssuerDNFree(DetectEngineCtx *, void *); static int DetectTlsFingerprintMatch (DetectEngineThreadCtx *, @@ -118,7 +116,6 @@ void DetectTlsRegister (void) sigmatch_table[DETECT_AL_TLS_SUBJECT].AppLayerTxMatch = DetectTlsSubjectMatch; sigmatch_table[DETECT_AL_TLS_SUBJECT].Setup = DetectTlsSubjectSetup; sigmatch_table[DETECT_AL_TLS_SUBJECT].Free = DetectTlsSubjectFree; - sigmatch_table[DETECT_AL_TLS_SUBJECT].RegisterTests = DetectTlsSubjectRegisterTests; sigmatch_table[DETECT_AL_TLS_SUBJECT].flags = SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION; sigmatch_table[DETECT_AL_TLS_SUBJECT].alternative = DETECT_AL_TLS_CERT_SUBJECT; @@ -128,7 +125,6 @@ void DetectTlsRegister (void) sigmatch_table[DETECT_AL_TLS_ISSUERDN].AppLayerTxMatch = DetectTlsIssuerDNMatch; sigmatch_table[DETECT_AL_TLS_ISSUERDN].Setup = DetectTlsIssuerDNSetup; sigmatch_table[DETECT_AL_TLS_ISSUERDN].Free = DetectTlsIssuerDNFree; - sigmatch_table[DETECT_AL_TLS_ISSUERDN].RegisterTests = DetectTlsIssuerDNRegisterTests; sigmatch_table[DETECT_AL_TLS_ISSUERDN].flags = SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION; sigmatch_table[DETECT_AL_TLS_ISSUERDN].alternative = DETECT_AL_TLS_CERT_ISSUER; @@ -138,7 +134,6 @@ void DetectTlsRegister (void) sigmatch_table[DETECT_AL_TLS_FINGERPRINT].AppLayerTxMatch = DetectTlsFingerprintMatch; sigmatch_table[DETECT_AL_TLS_FINGERPRINT].Setup = DetectTlsFingerprintSetup; sigmatch_table[DETECT_AL_TLS_FINGERPRINT].Free = DetectTlsFingerprintFree; - sigmatch_table[DETECT_AL_TLS_FINGERPRINT].RegisterTests = NULL; sigmatch_table[DETECT_AL_TLS_FINGERPRINT].flags = SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION; sigmatch_table[DETECT_AL_TLS_FINGERPRINT].alternative = DETECT_AL_TLS_CERT_FINGERPRINT; @@ -148,8 +143,6 @@ void DetectTlsRegister (void) sigmatch_table[DETECT_AL_TLS_STORE].url = "/rules/tls-keywords.html#tls-store"; sigmatch_table[DETECT_AL_TLS_STORE].Match = DetectTlsStorePostMatch; sigmatch_table[DETECT_AL_TLS_STORE].Setup = DetectTlsStoreSetup; - sigmatch_table[DETECT_AL_TLS_STORE].Free = NULL; - sigmatch_table[DETECT_AL_TLS_STORE].RegisterTests = NULL; sigmatch_table[DETECT_AL_TLS_STORE].flags |= SIGMATCH_NOOPT; DetectSetupParseRegexes(PARSE_REGEX, &subject_parse_regex); @@ -354,13 +347,6 @@ static void DetectTlsSubjectFree(DetectEngineCtx *de_ctx, void *ptr) SCFree(id_d); } -/** - * \brief this function registers unit tests for DetectTlsSubject - */ -static void DetectTlsSubjectRegisterTests(void) -{ -} - /** * \brief match the specified IssuerDN on a tls session * @@ -786,12 +772,4 @@ static int DetectTlsStorePostMatch (DetectEngineThreadCtx *det_ctx, ssl_state->server_connp.cert_log_flag |= SSL_TLS_LOG_PEM; SCReturnInt(1); -} - - -/** - * \brief this function registers unit tests for DetectTlsIssuerDN - */ -static void DetectTlsIssuerDNRegisterTests(void) -{ -} +} \ No newline at end of file diff --git a/src/detect-tos.c b/src/detect-tos.c index 746c6cce63..fe37b1977a 100644 --- a/src/detect-tos.c +++ b/src/detect-tos.c @@ -50,7 +50,9 @@ static DetectParseRegex parse_regex; static int DetectTosSetup(DetectEngineCtx *, Signature *, const char *); static int DetectTosMatch(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); +#ifdef UNITTESTS static void DetectTosRegisterTests(void); +#endif static void DetectTosFree(DetectEngineCtx *, void *); #define DETECT_IPTOS_MIN 0 @@ -66,7 +68,9 @@ void DetectTosRegister(void) sigmatch_table[DETECT_TOS].Match = DetectTosMatch; sigmatch_table[DETECT_TOS].Setup = DetectTosSetup; sigmatch_table[DETECT_TOS].Free = DetectTosFree; +#ifdef UNITTESTS sigmatch_table[DETECT_TOS].RegisterTests = DetectTosRegisterTests; +#endif sigmatch_table[DETECT_TOS].flags = (SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION); sigmatch_table[DETECT_TOS].url = @@ -346,11 +350,8 @@ end: return result; } -#endif - void DetectTosRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTosTest01", DetectTosTest01); UtRegisterTest("DetectTosTest02", DetectTosTest02); UtRegisterTest("DetectTosTest04", DetectTosTest04); @@ -361,6 +362,6 @@ void DetectTosRegisterTests(void) UtRegisterTest("DetectTosTest09", DetectTosTest09); UtRegisterTest("DetectTosTest10", DetectTosTest10); UtRegisterTest("DetectTosTest12", DetectTosTest12); -#endif return; } +#endif \ No newline at end of file diff --git a/src/detect-transform-compress-whitespace.c b/src/detect-transform-compress-whitespace.c index 4087b12111..e03f918c10 100644 --- a/src/detect-transform-compress-whitespace.c +++ b/src/detect-transform-compress-whitespace.c @@ -35,8 +35,9 @@ #include "util-print.h" static int DetectTransformCompressWhitespaceSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectTransformCompressWhitespaceRegisterTests(void); - +#endif static void TransformCompressWhitespace(InspectionBuffer *buffer, void *options); void DetectTransformCompressWhitespaceRegister(void) @@ -51,9 +52,10 @@ void DetectTransformCompressWhitespaceRegister(void) TransformCompressWhitespace; sigmatch_table[DETECT_TRANSFORM_COMPRESS_WHITESPACE].Setup = DetectTransformCompressWhitespaceSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_TRANSFORM_COMPRESS_WHITESPACE].RegisterTests = DetectTransformCompressWhitespaceRegisterTests; - +#endif sigmatch_table[DETECT_TRANSFORM_COMPRESS_WHITESPACE].flags |= SIGMATCH_NOOPT; } @@ -158,14 +160,11 @@ static int DetectTransformCompressWhitespaceTest02(void) PASS; } -#endif - static void DetectTransformCompressWhitespaceRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTransformCompressWhitespaceTest01", DetectTransformCompressWhitespaceTest01); UtRegisterTest("DetectTransformCompressWhitespaceTest02", DetectTransformCompressWhitespaceTest02); -#endif } +#endif \ No newline at end of file diff --git a/src/detect-transform-dotprefix.c b/src/detect-transform-dotprefix.c index b0fa5c6835..22fe0ff5ee 100644 --- a/src/detect-transform-dotprefix.c +++ b/src/detect-transform-dotprefix.c @@ -37,8 +37,9 @@ #include "util-memcpy.h" static int DetectTransformDotPrefixSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectTransformDotPrefixRegisterTests(void); - +#endif static void TransformDotPrefix(InspectionBuffer *buffer, void *options); void DetectTransformDotPrefixRegister(void) @@ -50,9 +51,10 @@ void DetectTransformDotPrefixRegister(void) "/rules/transforms.html#dotprefix"; sigmatch_table[DETECT_TRANSFORM_DOTPREFIX].Transform = TransformDotPrefix; sigmatch_table[DETECT_TRANSFORM_DOTPREFIX].Setup = DetectTransformDotPrefixSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_TRANSFORM_DOTPREFIX].RegisterTests = DetectTransformDotPrefixRegisterTests; - +#endif sigmatch_table[DETECT_TRANSFORM_DOTPREFIX].flags |= SIGMATCH_NOOPT; } @@ -173,13 +175,11 @@ static int DetectTransformDotPrefixTest03(void) DetectEngineCtxFree(de_ctx); PASS; } -#endif static void DetectTransformDotPrefixRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTransformDotPrefixTest01", DetectTransformDotPrefixTest01); UtRegisterTest("DetectTransformDotPrefixTest02", DetectTransformDotPrefixTest02); UtRegisterTest("DetectTransformDotPrefixTest03", DetectTransformDotPrefixTest03); -#endif } +#endif \ No newline at end of file diff --git a/src/detect-transform-md5.c b/src/detect-transform-md5.c index a2af21efdd..d8817252dd 100644 --- a/src/detect-transform-md5.c +++ b/src/detect-transform-md5.c @@ -36,7 +36,9 @@ static int DetectTransformToMd5Setup (DetectEngineCtx *, Signature *, const char *); #ifdef HAVE_NSS +#ifdef UNITTESTS static void DetectTransformToMd5RegisterTests(void); +#endif static void TransformToMd5(InspectionBuffer *buffer, void *options); #endif @@ -52,8 +54,10 @@ void DetectTransformMd5Register(void) #ifdef HAVE_NSS sigmatch_table[DETECT_TRANSFORM_MD5].Transform = TransformToMd5; +#ifdef UNITTESTS sigmatch_table[DETECT_TRANSFORM_MD5].RegisterTests = DetectTransformToMd5RegisterTests; +#endif #endif sigmatch_table[DETECT_TRANSFORM_MD5].flags |= SIGMATCH_NOOPT; } @@ -118,13 +122,10 @@ static int DetectTransformToMd5Test01(void) PASS; } -#endif - static void DetectTransformToMd5RegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTransformToMd5Test01", DetectTransformToMd5Test01); -#endif } #endif +#endif \ No newline at end of file diff --git a/src/detect-transform-sha1.c b/src/detect-transform-sha1.c index cd42151733..33df794d2c 100644 --- a/src/detect-transform-sha1.c +++ b/src/detect-transform-sha1.c @@ -36,7 +36,9 @@ static int DetectTransformToSha1Setup (DetectEngineCtx *, Signature *, const char *); #ifdef HAVE_NSS +#ifdef UNITTESTS static void DetectTransformToSha1RegisterTests(void); +#endif static void TransformToSha1(InspectionBuffer *buffer, void *options); #endif @@ -52,8 +54,10 @@ void DetectTransformSha1Register(void) #ifdef HAVE_NSS sigmatch_table[DETECT_TRANSFORM_SHA1].Transform = TransformToSha1; +#ifdef UNITTESTS sigmatch_table[DETECT_TRANSFORM_SHA1].RegisterTests = DetectTransformToSha1RegisterTests; +#endif #endif sigmatch_table[DETECT_TRANSFORM_SHA1].flags |= SIGMATCH_NOOPT; } @@ -118,13 +122,10 @@ static int DetectTransformToSha1Test01(void) PASS; } -#endif - static void DetectTransformToSha1RegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTransformToSha1Test01", DetectTransformToSha1Test01); -#endif } #endif +#endif \ No newline at end of file diff --git a/src/detect-transform-sha256.c b/src/detect-transform-sha256.c index b28b5492df..f7088746a1 100644 --- a/src/detect-transform-sha256.c +++ b/src/detect-transform-sha256.c @@ -36,7 +36,9 @@ static int DetectTransformToSha256Setup (DetectEngineCtx *, Signature *, const char *); #ifdef HAVE_NSS +#ifdef UNITTESTS static void DetectTransformToSha256RegisterTests(void); +#endif static void TransformToSha256(InspectionBuffer *buffer, void *options); #endif @@ -52,8 +54,10 @@ void DetectTransformSha256Register(void) #ifdef HAVE_NSS sigmatch_table[DETECT_TRANSFORM_SHA256].Transform = TransformToSha256; +#ifdef UNITTESTS sigmatch_table[DETECT_TRANSFORM_SHA256].RegisterTests = DetectTransformToSha256RegisterTests; +#endif #endif sigmatch_table[DETECT_TRANSFORM_SHA256].flags |= SIGMATCH_NOOPT; } @@ -118,13 +122,10 @@ static int DetectTransformToSha256Test01(void) PASS; } -#endif - static void DetectTransformToSha256RegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTransformToSha256Test01", DetectTransformToSha256Test01); -#endif } #endif +#endif \ No newline at end of file diff --git a/src/detect-transform-strip-whitespace.c b/src/detect-transform-strip-whitespace.c index 96f8234cb9..6757941f8c 100644 --- a/src/detect-transform-strip-whitespace.c +++ b/src/detect-transform-strip-whitespace.c @@ -35,8 +35,9 @@ #include "util-print.h" static int DetectTransformStripWhitespaceSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectTransformStripWhitespaceRegisterTests(void); - +#endif static void TransformStripWhitespace(InspectionBuffer *buffer, void *options); static bool TransformStripWhitespaceValidate(const uint8_t *content, uint16_t content_len, void *options); @@ -53,9 +54,10 @@ void DetectTransformStripWhitespaceRegister(void) TransformStripWhitespaceValidate; sigmatch_table[DETECT_TRANSFORM_STRIP_WHITESPACE].Setup = DetectTransformStripWhitespaceSetup; +#ifdef UNITTESTS sigmatch_table[DETECT_TRANSFORM_STRIP_WHITESPACE].RegisterTests = DetectTransformStripWhitespaceRegisterTests; - +#endif sigmatch_table[DETECT_TRANSFORM_STRIP_WHITESPACE].flags |= SIGMATCH_NOOPT; } @@ -191,16 +193,13 @@ static int DetectTransformStripWhitespaceTest03(void) PASS; } -#endif - static void DetectTransformStripWhitespaceRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectTransformStripWhitespaceTest01", DetectTransformStripWhitespaceTest01); UtRegisterTest("DetectTransformStripWhitespaceTest02", DetectTransformStripWhitespaceTest02); UtRegisterTest("DetectTransformStripWhitespaceTest03", DetectTransformStripWhitespaceTest03); -#endif } +#endif \ No newline at end of file diff --git a/src/detect-uricontent.c b/src/detect-uricontent.c index 26ff2370c8..df1c882091 100644 --- a/src/detect-uricontent.c +++ b/src/detect-uricontent.c @@ -57,7 +57,9 @@ /* prototypes */ static int DetectUricontentSetup (DetectEngineCtx *, Signature *, const char *); +#ifdef UNITTESTS static void DetectUricontentRegisterTests(void); +#endif static void DetectUricontentFree(DetectEngineCtx *de_ctx, void *); static int g_http_uri_buffer_id = 0; @@ -73,7 +75,9 @@ void DetectUricontentRegister (void) sigmatch_table[DETECT_URICONTENT].Match = NULL; sigmatch_table[DETECT_URICONTENT].Setup = DetectUricontentSetup; sigmatch_table[DETECT_URICONTENT].Free = DetectUricontentFree; +#ifdef UNITTESTS sigmatch_table[DETECT_URICONTENT].RegisterTests = DetectUricontentRegisterTests; +#endif sigmatch_table[DETECT_URICONTENT].flags = (SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION); sigmatch_table[DETECT_URICONTENT].alternative = DETECT_HTTP_URI; @@ -1746,11 +1750,8 @@ static int DetectUricontentIsdataatParseTest(void) PASS; } -#endif /* UNITTESTS */ - static void DetectUricontentRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("HTTPUriTest01", HTTPUriTest01); UtRegisterTest("HTTPUriTest02", HTTPUriTest02); UtRegisterTest("HTTPUriTest03", HTTPUriTest03); @@ -1784,5 +1785,5 @@ static void DetectUricontentRegisterTests(void) UtRegisterTest("DetectUricontentIsdataatParseTest", DetectUricontentIsdataatParseTest); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-urilen.c b/src/detect-urilen.c index 1e6bc05568..3ba4322c0f 100644 --- a/src/detect-urilen.c +++ b/src/detect-urilen.c @@ -51,9 +51,10 @@ static DetectParseRegex parse_regex; /*prototypes*/ static int DetectUrilenSetup (DetectEngineCtx *, Signature *, const char *); -void DetectUrilenFree (DetectEngineCtx *, void *); -void DetectUrilenRegisterTests (void); - +static void DetectUrilenFree (DetectEngineCtx *, void *); +#ifdef UNITTESTS +static void DetectUrilenRegisterTests (void); +#endif static int g_http_uri_buffer_id = 0; static int g_http_raw_uri_buffer_id = 0; @@ -69,8 +70,9 @@ void DetectUrilenRegister(void) sigmatch_table[DETECT_AL_URILEN].Match = NULL; sigmatch_table[DETECT_AL_URILEN].Setup = DetectUrilenSetup; sigmatch_table[DETECT_AL_URILEN].Free = DetectUrilenFree; +#ifdef UNITTESTS sigmatch_table[DETECT_AL_URILEN].RegisterTests = DetectUrilenRegisterTests; - +#endif DetectSetupParseRegexes(PARSE_REGEX, &parse_regex); g_http_uri_buffer_id = DetectBufferTypeRegister("http_uri"); @@ -88,7 +90,6 @@ void DetectUrilenRegister(void) static DetectUrilenData *DetectUrilenParse (const char *urilenstr) { - DetectUrilenData *urilend = NULL; char *arg1 = NULL; char *arg2 = NULL; @@ -274,7 +275,7 @@ error: * * \param ptr pointer to DetectUrilenData */ -void DetectUrilenFree(DetectEngineCtx *de_ctx, void *ptr) +static void DetectUrilenFree(DetectEngineCtx *de_ctx, void *ptr) { if (ptr == NULL) return; @@ -726,14 +727,11 @@ end: return result; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for DetectUrilen */ void DetectUrilenRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("DetectUrilenParseTest01", DetectUrilenParseTest01); UtRegisterTest("DetectUrilenParseTest02", DetectUrilenParseTest02); UtRegisterTest("DetectUrilenParseTest03", DetectUrilenParseTest03); @@ -746,5 +744,5 @@ void DetectUrilenRegisterTests(void) UtRegisterTest("DetectUrilenParseTest10", DetectUrilenParseTest10); UtRegisterTest("DetectUrilenSetpTest01", DetectUrilenSetpTest01); UtRegisterTest("DetectUrilenSigTest01", DetectUrilenSigTest01); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-within.c b/src/detect-within.c index b45db2a7c5..5bb89a1b2a 100644 --- a/src/detect-within.c +++ b/src/detect-within.c @@ -45,7 +45,9 @@ #include "util-unittest.h" static int DetectWithinSetup(DetectEngineCtx *, Signature *, const char *); -void DetectWithinRegisterTests(void); +#ifdef UNITTESTS +static void DetectWithinRegisterTests(void); +#endif void DetectWithinRegister(void) { @@ -54,8 +56,9 @@ void DetectWithinRegister(void) sigmatch_table[DETECT_WITHIN].url = "/rules/payload-keywords.html#within"; sigmatch_table[DETECT_WITHIN].Match = NULL; sigmatch_table[DETECT_WITHIN].Setup = DetectWithinSetup; - sigmatch_table[DETECT_WITHIN].Free = NULL; +#ifdef UNITTESTS sigmatch_table[DETECT_WITHIN].RegisterTests = DetectWithinRegisterTests; +#endif } /** \brief Setup within pattern (content/uricontent) modifier. @@ -229,13 +232,10 @@ static int DetectWithinTestVarSetup(void) PASS; } -#endif /* UNITTESTS */ - void DetectWithinRegisterTests(void) { - #ifdef UNITTESTS UtRegisterTest("DetectWithinTestPacket01", DetectWithinTestPacket01); UtRegisterTest("DetectWithinTestPacket02", DetectWithinTestPacket02); UtRegisterTest("DetectWithinTestVarSetup", DetectWithinTestVarSetup); - #endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect-xbits.c b/src/detect-xbits.c index 31b0a6b697..5645fdcdaf 100644 --- a/src/detect-xbits.c +++ b/src/detect-xbits.c @@ -59,8 +59,10 @@ static DetectParseRegex parse_regex; static int DetectXbitMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *); static int DetectXbitSetup (DetectEngineCtx *, Signature *, const char *); -void DetectXbitFree (DetectEngineCtx *, void *); -void XBitsRegisterTests(void); +#ifdef UNITTESTS +static void XBitsRegisterTests(void); +#endif +static void DetectXbitFree (DetectEngineCtx *, void *); void DetectXbitsRegister (void) { @@ -70,7 +72,9 @@ void DetectXbitsRegister (void) sigmatch_table[DETECT_XBITS].Match = DetectXbitMatch; sigmatch_table[DETECT_XBITS].Setup = DetectXbitSetup; sigmatch_table[DETECT_XBITS].Free = DetectXbitFree; +#ifdef UNITTESTS sigmatch_table[DETECT_XBITS].RegisterTests = XBitsRegisterTests; +#endif /* this is compatible to ip-only signatures */ sigmatch_table[DETECT_XBITS].flags |= SIGMATCH_IPONLY_COMPAT; @@ -363,7 +367,7 @@ error: return -1; } -void DetectXbitFree (DetectEngineCtx *de_ctx, void *ptr) +static void DetectXbitFree (DetectEngineCtx *de_ctx, void *ptr) { DetectXbitsData *fd = (DetectXbitsData *)ptr; @@ -534,16 +538,13 @@ static int XBitsTestSig02(void) PASS; } -#endif /* UNITTESTS */ - /** * \brief this function registers unit tests for XBits */ -void XBitsRegisterTests(void) +static void XBitsRegisterTests(void) { -#ifdef UNITTESTS UtRegisterTest("XBitsTestParse01", XBitsTestParse01); UtRegisterTest("XBitsTestSig01", XBitsTestSig01); UtRegisterTest("XBitsTestSig02", XBitsTestSig02); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ \ No newline at end of file diff --git a/src/detect.h b/src/detect.h index eab188d9dd..2499552ef1 100644 --- a/src/detect.h +++ b/src/detect.h @@ -1198,8 +1198,9 @@ typedef struct SigTableElmt_ { int (*SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh); void (*Free)(DetectEngineCtx *, void *); +#ifdef UNITTESTS void (*RegisterTests)(void); - +#endif uint16_t flags; /* coccinelle: SigTableElmt:flags:SIGMATCH_ */