detect: hide RegisterTests behind ifdef UNITTESTS

Update all callers to more aggressively use UNITTESTS guards as well.
pull/5216/head
Victor Julien 6 years ago
parent 071f55dcd7
commit 6ab323d323

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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

@ -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:<pattern len>')";

@ -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 */

@ -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 */

@ -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

@ -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

@ -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 */

@ -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 */

@ -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

@ -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

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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);
}

@ -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 */

@ -49,10 +49,4 @@ typedef struct DetectFragBitsData_ {
void DetectFragBitsRegister (void);
/**
* This function registers unit tests for FragBits
*/
void FragBitsRegisterTests(void);
#endif /*__DETECT_FRAGBITS_H__ */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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__ */

@ -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 */

@ -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 */
/**
* @}
*/

@ -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 */
/**
* @}
*/

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -52,10 +52,4 @@ typedef struct DetectMarkData_ {
void DetectMarkRegister (void);
/**
* This function registers unit tests for Mark
*/
void MarkRegisterTests(void);
#endif /*__DETECT_MARK_H__ */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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;
}

@ -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;
}

@ -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)

@ -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 */

@ -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

@ -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);
}

@ -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;
}

@ -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 */

@ -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 */

@ -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;
}
}

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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;

@ -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;

@ -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;

@ -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;

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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 */

@ -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);

@ -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 */

@ -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 */

@ -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 */

@ -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 */
/**
* @}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save