From: Victor Julien Date: Fri, 24 Jul 2020 11:03:58 +0000 (+0200) Subject: sources: hide RegisterTests behind ifdef UNITTESTS X-Git-Tag: suricata-6.0.0-beta1~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5216%2Fhead;p=thirdparty%2Fsuricata.git sources: hide RegisterTests behind ifdef UNITTESTS Update callers. --- diff --git a/src/respond-reject.c b/src/respond-reject.c index b3b37848b4..b9a1740676 100644 --- a/src/respond-reject.c +++ b/src/respond-reject.c @@ -52,7 +52,6 @@ void TmModuleRespondRejectRegister (void) tmm_modules[TMM_RESPONDREJECT].ThreadInit = NULL; tmm_modules[TMM_RESPONDREJECT].Func = RespondRejectFunc; tmm_modules[TMM_RESPONDREJECT].ThreadDeinit = RespondRejectThreadDeinit; - tmm_modules[TMM_RESPONDREJECT].RegisterTests = NULL; tmm_modules[TMM_RESPONDREJECT].cap_flags = 0; /* libnet is not compat with caps */ } diff --git a/src/source-af-packet.c b/src/source-af-packet.c index c6c46ae44f..4ef99dc341 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -129,7 +129,6 @@ void TmModuleReceiveAFPRegister (void) tmm_modules[TMM_RECEIVEAFP].Func = NULL; tmm_modules[TMM_RECEIVEAFP].ThreadExitPrintStats = NULL; tmm_modules[TMM_RECEIVEAFP].ThreadDeinit = NULL; - tmm_modules[TMM_RECEIVEAFP].RegisterTests = NULL; tmm_modules[TMM_RECEIVEAFP].cap_flags = 0; tmm_modules[TMM_RECEIVEAFP].flags = TM_FLAG_RECEIVE_TM; } @@ -144,7 +143,6 @@ void TmModuleDecodeAFPRegister (void) tmm_modules[TMM_DECODEAFP].Func = NULL; tmm_modules[TMM_DECODEAFP].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEAFP].ThreadDeinit = NULL; - tmm_modules[TMM_DECODEAFP].RegisterTests = NULL; tmm_modules[TMM_DECODEAFP].cap_flags = 0; tmm_modules[TMM_DECODEAFP].flags = TM_FLAG_DECODE_TM; } @@ -332,7 +330,6 @@ void TmModuleReceiveAFPRegister (void) tmm_modules[TMM_RECEIVEAFP].PktAcqBreakLoop = NULL; tmm_modules[TMM_RECEIVEAFP].ThreadExitPrintStats = ReceiveAFPThreadExitStats; tmm_modules[TMM_RECEIVEAFP].ThreadDeinit = ReceiveAFPThreadDeinit; - tmm_modules[TMM_RECEIVEAFP].RegisterTests = NULL; tmm_modules[TMM_RECEIVEAFP].cap_flags = SC_CAP_NET_RAW; tmm_modules[TMM_RECEIVEAFP].flags = TM_FLAG_RECEIVE_TM; @@ -550,7 +547,6 @@ void TmModuleDecodeAFPRegister (void) tmm_modules[TMM_DECODEAFP].Func = DecodeAFP; tmm_modules[TMM_DECODEAFP].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEAFP].ThreadDeinit = DecodeAFPThreadDeinit; - tmm_modules[TMM_DECODEAFP].RegisterTests = NULL; tmm_modules[TMM_DECODEAFP].cap_flags = 0; tmm_modules[TMM_DECODEAFP].flags = TM_FLAG_DECODE_TM; } diff --git a/src/source-erf-dag.c b/src/source-erf-dag.c index 3ab39b7fe1..ba5b17b5e4 100644 --- a/src/source-erf-dag.c +++ b/src/source-erf-dag.c @@ -47,7 +47,6 @@ TmModuleReceiveErfDagRegister(void) tmm_modules[TMM_RECEIVEERFDAG].Func = NULL; tmm_modules[TMM_RECEIVEERFDAG].ThreadExitPrintStats = NULL; tmm_modules[TMM_RECEIVEERFDAG].ThreadDeinit = NULL; - tmm_modules[TMM_RECEIVEERFDAG].RegisterTests = NULL; tmm_modules[TMM_RECEIVEERFDAG].cap_flags = SC_CAP_NET_ADMIN; tmm_modules[TMM_RECEIVEERFDAG].flags = TM_FLAG_RECEIVE_TM; } @@ -60,7 +59,6 @@ TmModuleDecodeErfDagRegister(void) tmm_modules[TMM_DECODEERFDAG].Func = NULL; tmm_modules[TMM_DECODEERFDAG].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEERFDAG].ThreadDeinit = NULL; - tmm_modules[TMM_DECODEERFDAG].RegisterTests = NULL; tmm_modules[TMM_DECODEERFDAG].cap_flags = 0; tmm_modules[TMM_DECODEERFDAG].flags = TM_FLAG_DECODE_TM; } @@ -141,7 +139,6 @@ TmModuleReceiveErfDagRegister(void) tmm_modules[TMM_RECEIVEERFDAG].ThreadExitPrintStats = ReceiveErfDagThreadExitStats; tmm_modules[TMM_RECEIVEERFDAG].ThreadDeinit = NULL; - tmm_modules[TMM_RECEIVEERFDAG].RegisterTests = NULL; tmm_modules[TMM_RECEIVEERFDAG].cap_flags = 0; tmm_modules[TMM_RECEIVEERFDAG].flags = TM_FLAG_RECEIVE_TM; } @@ -157,7 +154,6 @@ TmModuleDecodeErfDagRegister(void) tmm_modules[TMM_DECODEERFDAG].Func = DecodeErfDag; tmm_modules[TMM_DECODEERFDAG].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEERFDAG].ThreadDeinit = DecodeErfDagThreadDeinit; - tmm_modules[TMM_DECODEERFDAG].RegisterTests = NULL; tmm_modules[TMM_DECODEERFDAG].cap_flags = 0; tmm_modules[TMM_DECODEERFDAG].flags = TM_FLAG_DECODE_TM; } diff --git a/src/source-erf-file.c b/src/source-erf-file.c index 853a45a152..4f1a4346ee 100644 --- a/src/source-erf-file.c +++ b/src/source-erf-file.c @@ -86,7 +86,6 @@ TmModuleReceiveErfFileRegister(void) tmm_modules[TMM_RECEIVEERFFILE].ThreadExitPrintStats = ReceiveErfFileThreadExitStats; tmm_modules[TMM_RECEIVEERFFILE].ThreadDeinit = NULL; - tmm_modules[TMM_RECEIVEERFFILE].RegisterTests = NULL; tmm_modules[TMM_RECEIVEERFFILE].cap_flags = 0; tmm_modules[TMM_RECEIVEERFFILE].flags = TM_FLAG_RECEIVE_TM; } @@ -102,7 +101,6 @@ TmModuleDecodeErfFileRegister(void) tmm_modules[TMM_DECODEERFFILE].Func = DecodeErfFile; tmm_modules[TMM_DECODEERFFILE].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEERFFILE].ThreadDeinit = DecodeErfFileThreadDeinit; - tmm_modules[TMM_DECODEERFFILE].RegisterTests = NULL; tmm_modules[TMM_DECODEERFFILE].cap_flags = 0; tmm_modules[TMM_DECODEERFFILE].flags = TM_FLAG_DECODE_TM; } diff --git a/src/source-ipfw.c b/src/source-ipfw.c index 1a33c7a307..0d39cf9092 100644 --- a/src/source-ipfw.c +++ b/src/source-ipfw.c @@ -64,7 +64,6 @@ void TmModuleReceiveIPFWRegister (void) tmm_modules[TMM_RECEIVEIPFW].Func = NULL; tmm_modules[TMM_RECEIVEIPFW].ThreadExitPrintStats = NULL; tmm_modules[TMM_RECEIVEIPFW].ThreadDeinit = NULL; - tmm_modules[TMM_RECEIVEIPFW].RegisterTests = NULL; tmm_modules[TMM_RECEIVEIPFW].flags = TM_FLAG_RECEIVE_TM; } @@ -75,7 +74,6 @@ void TmModuleVerdictIPFWRegister (void) tmm_modules[TMM_VERDICTIPFW].Func = NULL; tmm_modules[TMM_VERDICTIPFW].ThreadExitPrintStats = NULL; tmm_modules[TMM_VERDICTIPFW].ThreadDeinit = NULL; - tmm_modules[TMM_VERDICTIPFW].RegisterTests = NULL; } void TmModuleDecodeIPFWRegister (void) @@ -85,7 +83,6 @@ void TmModuleDecodeIPFWRegister (void) tmm_modules[TMM_DECODEIPFW].Func = NULL; tmm_modules[TMM_DECODEIPFW].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEIPFW].ThreadDeinit = NULL; - tmm_modules[TMM_DECODEIPFW].RegisterTests = NULL; tmm_modules[TMM_DECODEIPFW].cap_flags = 0; tmm_modules[TMM_DECODEIPFW].flags = TM_FLAG_DECODE_TM; } @@ -164,7 +161,6 @@ void TmModuleReceiveIPFWRegister (void) tmm_modules[TMM_RECEIVEIPFW].cap_flags = SC_CAP_NET_ADMIN | SC_CAP_NET_RAW | SC_CAP_NET_BIND_SERVICE | SC_CAP_NET_BROADCAST; /** \todo untested */ - tmm_modules[TMM_RECEIVEIPFW].RegisterTests = NULL; tmm_modules[TMM_RECEIVEIPFW].flags = TM_FLAG_RECEIVE_TM; } @@ -181,7 +177,6 @@ void TmModuleVerdictIPFWRegister (void) tmm_modules[TMM_VERDICTIPFW].ThreadDeinit = VerdictIPFWThreadDeinit; tmm_modules[TMM_VERDICTIPFW].cap_flags = SC_CAP_NET_ADMIN | SC_CAP_NET_RAW | SC_CAP_NET_BIND_SERVICE; /** \todo untested */ - tmm_modules[TMM_VERDICTIPFW].RegisterTests = NULL; } /** @@ -195,7 +190,6 @@ void TmModuleDecodeIPFWRegister (void) tmm_modules[TMM_DECODEIPFW].Func = DecodeIPFW; tmm_modules[TMM_DECODEIPFW].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEIPFW].ThreadDeinit = DecodeIPFWThreadDeinit; - tmm_modules[TMM_DECODEIPFW].RegisterTests = NULL; tmm_modules[TMM_DECODEIPFW].flags = TM_FLAG_DECODE_TM; } diff --git a/src/source-napatech.c b/src/source-napatech.c index 9cc16f3ed8..0374688d91 100644 --- a/src/source-napatech.c +++ b/src/source-napatech.c @@ -48,7 +48,6 @@ void TmModuleNapatechStreamRegister(void) tmm_modules[TMM_RECEIVENAPATECH].Func = NULL; tmm_modules[TMM_RECEIVENAPATECH].ThreadExitPrintStats = NULL; tmm_modules[TMM_RECEIVENAPATECH].ThreadDeinit = NULL; - tmm_modules[TMM_RECEIVENAPATECH].RegisterTests = NULL; tmm_modules[TMM_RECEIVENAPATECH].cap_flags = SC_CAP_NET_ADMIN; } @@ -59,7 +58,6 @@ void TmModuleNapatechDecodeRegister(void) tmm_modules[TMM_DECODENAPATECH].Func = NULL; tmm_modules[TMM_DECODENAPATECH].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODENAPATECH].ThreadDeinit = NULL; - tmm_modules[TMM_DECODENAPATECH].RegisterTests = NULL; tmm_modules[TMM_DECODENAPATECH].cap_flags = 0; tmm_modules[TMM_DECODENAPATECH].flags = TM_FLAG_DECODE_TM; } @@ -136,7 +134,6 @@ void TmModuleNapatechStreamRegister(void) tmm_modules[TMM_RECEIVENAPATECH].PktAcqBreakLoop = NULL; tmm_modules[TMM_RECEIVENAPATECH].ThreadExitPrintStats = NapatechStreamThreadExitStats; tmm_modules[TMM_RECEIVENAPATECH].ThreadDeinit = NapatechStreamThreadDeinit; - tmm_modules[TMM_RECEIVENAPATECH].RegisterTests = NULL; tmm_modules[TMM_RECEIVENAPATECH].cap_flags = SC_CAP_NET_RAW; tmm_modules[TMM_RECEIVENAPATECH].flags = TM_FLAG_RECEIVE_TM; @@ -167,7 +164,6 @@ void TmModuleNapatechDecodeRegister(void) tmm_modules[TMM_DECODENAPATECH].Func = NapatechDecode; tmm_modules[TMM_DECODENAPATECH].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODENAPATECH].ThreadDeinit = NapatechDecodeThreadDeinit; - tmm_modules[TMM_DECODENAPATECH].RegisterTests = NULL; tmm_modules[TMM_DECODENAPATECH].cap_flags = 0; tmm_modules[TMM_DECODENAPATECH].flags = TM_FLAG_DECODE_TM; } diff --git a/src/source-nflog.c b/src/source-nflog.c index 74fafdf67d..492bd374ba 100644 --- a/src/source-nflog.c +++ b/src/source-nflog.c @@ -120,7 +120,6 @@ void TmModuleReceiveNFLOGRegister (void) tmm_modules[TMM_RECEIVENFLOG].PktAcqBreakLoop = NULL; tmm_modules[TMM_RECEIVENFLOG].ThreadExitPrintStats = ReceiveNFLOGThreadExitStats; tmm_modules[TMM_RECEIVENFLOG].ThreadDeinit = ReceiveNFLOGThreadDeinit; - tmm_modules[TMM_RECEIVENFLOG].RegisterTests = NULL; tmm_modules[TMM_RECEIVENFLOG].flags = TM_FLAG_RECEIVE_TM; } @@ -134,7 +133,6 @@ void TmModuleDecodeNFLOGRegister (void) tmm_modules[TMM_DECODENFLOG].Func = DecodeNFLOG; tmm_modules[TMM_DECODENFLOG].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODENFLOG].ThreadDeinit = DecodeNFLOGThreadDeinit; - tmm_modules[TMM_DECODENFLOG].RegisterTests = NULL; tmm_modules[TMM_DECODENFLOG].flags = TM_FLAG_DECODE_TM; } diff --git a/src/source-nfq.c b/src/source-nfq.c index 6a42cfde26..e07c7c27f0 100644 --- a/src/source-nfq.c +++ b/src/source-nfq.c @@ -63,7 +63,6 @@ void TmModuleReceiveNFQRegister (void) tmm_modules[TMM_RECEIVENFQ].ThreadInit = NoNFQSupportExit; tmm_modules[TMM_RECEIVENFQ].ThreadExitPrintStats = NULL; tmm_modules[TMM_RECEIVENFQ].ThreadDeinit = NULL; - tmm_modules[TMM_RECEIVENFQ].RegisterTests = NULL; tmm_modules[TMM_RECEIVENFQ].cap_flags = SC_CAP_NET_ADMIN; tmm_modules[TMM_RECEIVENFQ].flags = TM_FLAG_RECEIVE_TM; } @@ -74,7 +73,6 @@ void TmModuleVerdictNFQRegister (void) tmm_modules[TMM_VERDICTNFQ].ThreadInit = NoNFQSupportExit; tmm_modules[TMM_VERDICTNFQ].ThreadExitPrintStats = NULL; tmm_modules[TMM_VERDICTNFQ].ThreadDeinit = NULL; - tmm_modules[TMM_VERDICTNFQ].RegisterTests = NULL; tmm_modules[TMM_VERDICTNFQ].cap_flags = SC_CAP_NET_ADMIN; } @@ -84,7 +82,6 @@ void TmModuleDecodeNFQRegister (void) tmm_modules[TMM_DECODENFQ].ThreadInit = NoNFQSupportExit; tmm_modules[TMM_DECODENFQ].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODENFQ].ThreadDeinit = NULL; - tmm_modules[TMM_DECODENFQ].RegisterTests = NULL; tmm_modules[TMM_DECODENFQ].cap_flags = 0; tmm_modules[TMM_DECODENFQ].flags = TM_FLAG_DECODE_TM; } @@ -189,7 +186,6 @@ void TmModuleVerdictNFQRegister (void) tmm_modules[TMM_VERDICTNFQ].ThreadInit = VerdictNFQThreadInit; tmm_modules[TMM_VERDICTNFQ].Func = VerdictNFQ; tmm_modules[TMM_VERDICTNFQ].ThreadDeinit = VerdictNFQThreadDeinit; - tmm_modules[TMM_VERDICTNFQ].RegisterTests = NULL; } void TmModuleDecodeNFQRegister (void) diff --git a/src/source-pcap-file.c b/src/source-pcap-file.c index b811d4e3a1..2ec57cfd7f 100644 --- a/src/source-pcap-file.c +++ b/src/source-pcap-file.c @@ -118,7 +118,6 @@ void TmModuleReceivePcapFileRegister (void) tmm_modules[TMM_RECEIVEPCAPFILE].PktAcqBreakLoop = NULL; tmm_modules[TMM_RECEIVEPCAPFILE].ThreadExitPrintStats = ReceivePcapFileThreadExitStats; tmm_modules[TMM_RECEIVEPCAPFILE].ThreadDeinit = ReceivePcapFileThreadDeinit; - tmm_modules[TMM_RECEIVEPCAPFILE].RegisterTests = NULL; tmm_modules[TMM_RECEIVEPCAPFILE].cap_flags = 0; tmm_modules[TMM_RECEIVEPCAPFILE].flags = TM_FLAG_RECEIVE_TM; } @@ -130,7 +129,6 @@ void TmModuleDecodePcapFileRegister (void) tmm_modules[TMM_DECODEPCAPFILE].Func = DecodePcapFile; tmm_modules[TMM_DECODEPCAPFILE].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEPCAPFILE].ThreadDeinit = DecodePcapFileThreadDeinit; - tmm_modules[TMM_DECODEPCAPFILE].RegisterTests = NULL; tmm_modules[TMM_DECODEPCAPFILE].cap_flags = 0; tmm_modules[TMM_DECODEPCAPFILE].flags = TM_FLAG_DECODE_TM; } diff --git a/src/source-pcap.c b/src/source-pcap.c index 7ee7be502b..63cc425d17 100644 --- a/src/source-pcap.c +++ b/src/source-pcap.c @@ -116,7 +116,9 @@ static TmEcode DecodePcapThreadInit(ThreadVars *, const void *, void **); static TmEcode DecodePcapThreadDeinit(ThreadVars *tv, void *data); static TmEcode DecodePcap(ThreadVars *, Packet *, void *); -void SourcePcapRegisterTests(void); +#ifdef UNITTESTS +static void SourcePcapRegisterTests(void); +#endif /** protect pcap_compile and pcap_setfilter, as they are not thread safe: * http://seclists.org/tcpdump/2009/q1/62 */ @@ -134,7 +136,9 @@ void TmModuleReceivePcapRegister (void) tmm_modules[TMM_RECEIVEPCAP].ThreadExitPrintStats = ReceivePcapThreadExitStats; tmm_modules[TMM_RECEIVEPCAP].cap_flags = SC_CAP_NET_RAW; tmm_modules[TMM_RECEIVEPCAP].flags = TM_FLAG_RECEIVE_TM; +#ifdef UNITTESTS tmm_modules[TMM_RECEIVEPCAP].RegisterTests = SourcePcapRegisterTests; +#endif } /** @@ -711,14 +715,11 @@ void PcapTranslateIPToDevice(char *pcap_dev, size_t len) #ifdef UNITTESTS #include "tests/source-pcap.c" -#endif /* UNITTESTS */ - /** * \brief Register the Unit tests for pcap source */ -void SourcePcapRegisterTests(void) +static void SourcePcapRegisterTests(void) { -#ifdef UNITTESTS SourcePcapRegisterStatsTests(); -#endif /* UNITTESTS */ } +#endif /* UNITTESTS */ diff --git a/src/source-pfring.c b/src/source-pfring.c index 6e81a94dab..bafd80f15e 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -70,7 +70,6 @@ void TmModuleReceivePfringRegister (void) tmm_modules[TMM_RECEIVEPFRING].Func = NULL; tmm_modules[TMM_RECEIVEPFRING].ThreadExitPrintStats = NULL; tmm_modules[TMM_RECEIVEPFRING].ThreadDeinit = NULL; - tmm_modules[TMM_RECEIVEPFRING].RegisterTests = NULL; tmm_modules[TMM_RECEIVEPFRING].cap_flags = SC_CAP_NET_ADMIN | SC_CAP_NET_RAW | SC_CAP_NET_BIND_SERVICE | SC_CAP_NET_BROADCAST; tmm_modules[TMM_RECEIVEPFRING].flags = TM_FLAG_RECEIVE_TM; @@ -83,7 +82,6 @@ void TmModuleDecodePfringRegister (void) tmm_modules[TMM_DECODEPFRING].Func = NULL; tmm_modules[TMM_DECODEPFRING].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEPFRING].ThreadDeinit = NULL; - tmm_modules[TMM_DECODEPFRING].RegisterTests = NULL; tmm_modules[TMM_DECODEPFRING].cap_flags = 0; tmm_modules[TMM_DECODEPFRING].flags = TM_FLAG_DECODE_TM; } @@ -169,7 +167,6 @@ void TmModuleReceivePfringRegister (void) tmm_modules[TMM_RECEIVEPFRING].PktAcqBreakLoop = PfringBreakLoop; tmm_modules[TMM_RECEIVEPFRING].ThreadExitPrintStats = ReceivePfringThreadExitStats; tmm_modules[TMM_RECEIVEPFRING].ThreadDeinit = ReceivePfringThreadDeinit; - tmm_modules[TMM_RECEIVEPFRING].RegisterTests = NULL; tmm_modules[TMM_RECEIVEPFRING].flags = TM_FLAG_RECEIVE_TM; } @@ -184,7 +181,6 @@ void TmModuleDecodePfringRegister (void) tmm_modules[TMM_DECODEPFRING].Func = DecodePfring; tmm_modules[TMM_DECODEPFRING].ThreadExitPrintStats = NULL; tmm_modules[TMM_DECODEPFRING].ThreadDeinit = DecodePfringThreadDeinit; - tmm_modules[TMM_DECODEPFRING].RegisterTests = NULL; tmm_modules[TMM_DECODEPFRING].flags = TM_FLAG_DECODE_TM; } diff --git a/src/tm-modules.h b/src/tm-modules.h index a3c040028e..7df5b91be3 100644 --- a/src/tm-modules.h +++ b/src/tm-modules.h @@ -61,9 +61,9 @@ typedef struct TmModule_ { /** global Init/DeInit */ TmEcode (*Init)(void); TmEcode (*DeInit)(void); - +#ifdef UNITTESTS void (*RegisterTests)(void); - +#endif uint8_t cap_flags; /**< Flags to indicate the capability requierment of the given TmModule */ /* Other flags used by the module */