suricata
|
Unit testing support functions. More...
Data Structures | |
struct | UtTest_ |
Macros | |
#define | FAIL |
Fail a test. | |
#define | FAIL_IF(expr) |
Fail a test if expression evaluates to true. | |
#define | FAIL_IF_NOT(expr) |
Fail a test if expression evaluates to false. | |
#define | FAIL_IF_NULL(expr) |
Fail a test if expression evaluates to NULL. | |
#define | FAIL_IF_NOT_NULL(expr) |
Fail a test if expression evaluates to non-NULL. | |
#define | PASS |
Pass the test. | |
Typedefs | |
typedef struct UtTest_ | UtTest |
Functions | |
void | UtRegisterTest (const char *name, int(*TestFn)(void)) |
Register unit test. | |
void | UtListTests (const char *regex_arg) |
List all registered unit tests. | |
uint32_t | UtRunTests (const char *regex_arg) |
Run all registered unittests. | |
void | UtInitialize (void) |
Initialize unit test list. | |
void | UtCleanup (void) |
Cleanup unit test list. | |
void | UtRunModeRegister (void) |
int | UtRunSelftest (const char *regex_arg) |
Run self tests. | |
Variables | |
int | unittests_fatal = 0 |
int | unittests_fatal |
Unit testing support functions.
#define FAIL |
Fail a test.
Definition at line 60 of file util-unittest.h.
#define FAIL_IF | ( | expr | ) |
Fail a test if expression evaluates to true.
Definition at line 71 of file util-unittest.h.
#define FAIL_IF_NOT | ( | expr | ) |
Fail a test if expression evaluates to false.
Definition at line 82 of file util-unittest.h.
#define FAIL_IF_NOT_NULL | ( | expr | ) |
Fail a test if expression evaluates to non-NULL.
Definition at line 96 of file util-unittest.h.
#define FAIL_IF_NULL | ( | expr | ) |
Fail a test if expression evaluates to NULL.
Definition at line 89 of file util-unittest.h.
#define PASS |
Pass the test.
Only to be used at the end of a function instead of "return 1."
Definition at line 105 of file util-unittest.h.
void UtCleanup | ( | void | ) |
Cleanup unit test list.
Definition at line 269 of file util-unittest.c.
References UtTest_::next, and SCFree.
Referenced by RunUnittests(), and UtRunSelftest().
void UtInitialize | ( | void | ) |
Initialize unit test list.
Definition at line 260 of file util-unittest.c.
Referenced by RunUnittests(), and UtRunSelftest().
void UtListTests | ( | const char * | regex_arg | ) |
List all registered unit tests.
regex_arg | Regular expression to limit listed tests. |
Definition at line 157 of file util-unittest.c.
References UtTest_::name, UtTest_::next, and regex_arg.
Referenced by RunUnittests().
void UtRegisterTest | ( | const char * | name, |
int(*)(void) | TestFn | ||
) |
Register unit test.
name | Unit test name |
TestFn | Unit test function |
Definition at line 103 of file util-unittest.c.
References name, UtTest_::name, UtTest_::next, and UtTest_::TestFn.
Referenced by AlertFastLogRegisterTests(), AppLayerHtpFileRegisterTests(), AppLayerProtoDetectUnittestsRegister(), AppLayerUnittestsRegister(), ByteRegisterTests(), CoredumpConfigRegisterTests(), DcePayloadRegisterTests(), DecodeCHDLCRegisterTests(), DecodeESPRegisterTests(), DecodeEthernetRegisterTests(), DecodeGeneveRegisterTests(), DecodeGRERegisterTests(), DecodeICMPV4RegisterTests(), DecodeICMPV6RegisterTests(), DecodeIPV4RegisterTests(), DecodeIPV6RegisterTests(), DecodeMPLSRegisterTests(), DecodeNSHRegisterTests(), DecodePPPOERegisterTests(), DecodePPPRegisterTests(), DecodeRawRegisterTests(), DecodeTCPRegisterTests(), DecodeUDPV4RegisterTests(), DecodeVLANRegisterTests(), DecodeVNTagRegisterTests(), DecodeVXLANRegisterTests(), DefragRegisterTests(), DeStateRegisterTests(), DetectAddressIPv4Tests(), DetectAddressIPv6Tests(), DetectAddressTests(), DetectEngineAlertRegisterTests(), DetectEngineContentInspectionRegisterTests(), DetectEngineRegisterTests(), DetectEngineTagRegisterTests(), DetectFiledataRegisterTests(), DetectFragOffsetRegisterTests(), DetectHTTP2errorCodeRegisterTests(), DetectHTTP2frameTypeRegisterTests(), DetectHTTP2priorityRegisterTests(), DetectHTTP2settingsRegisterTests(), DetectHTTP2sizeUpdateRegisterTests(), DetectHTTP2windowRegisterTests(), DetectHttpClientBodyRegisterTests(), DetectHttpCookieRegisterTests(), DetectHttpHeaderRegisterTests(), DetectHttpHHRegisterTests(), DetectHttpMethodRegisterTests(), DetectHttpRawHeaderRegisterTests(), DetectHttpServerBodyRegisterTests(), DetectHttpStatCodeRegisterTests(), DetectHttpStatMsgRegisterTests(), DetectIcmpv4HdrRegisterTests(), DetectICMPv6hdrRegisterTests(), DetectICMPv6mtuRegisterTests(), DetectIPAddrRegisterTests(), DetectIpv4hdrRegisterTests(), DetectIpv6hdrRegisterTests(), DetectParseRegisterTests(), DetectPortTests(), DetectProtoTests(), DetectTcphdrRegisterTests(), DetectTemplateRegisterTests(), DetectTransformPcrexformRegisterTests(), DetectTtlRegisterTests(), DetectUdphdrRegisterTests(), DNP3ParserRegisterTests(), EngineEventRegisterTests(), FlowBitRegisterTests(), FlowBitsRegisterTests(), FlowRateRegisterTests(), FlowRegisterTests(), FTPParserRegisterTests(), HashListTableRegisterTests(), HashTableRegisterTests(), HostBitRegisterTests(), HostBitsRegisterTests(), HTPFileParserRegisterTests(), HTPXFFParserRegisterTests(), IKEChosenSaRegisterTests(), IKEParserRegisterTests(), IPOnlyRegisterTests(), IPPairBitRegisterTests(), MacSetRegisterTests(), MagicRegisterTests(), MemcmpRegisterTests(), MemrchrRegisterTests(), ModbusParserRegisterTests(), OutputJsonStatsRegisterTests(), PayloadRegisterTests(), PoolRegisterTests(), PoolThreadRegisterTests(), RegisterFlowStorageTests(), RegisterHostStorageTests(), RegisterIPPairStorageTests(), RegisterThreadStorageTests(), SCAtomicRegisterTests(), SCClassConfRegisterTests(), SCConfRegisterTests(), SCConfYamlRegisterTests(), SCHInfoRegisterTests(), SCLogRegisterTests(), SCProfilingRegisterTests(), SCProtoNameRegisterTests(), SCRadix4RegisterTests(), SCRadix6RegisterTests(), SCRConfRegisterTests(), SCReputationRegisterTests(), SCRuleVarsRegisterTests(), SCSigRegisterSignatureOrderingTests(), SCThresholdConfRegisterTests(), SigGroupHeadRegisterTests(), SigParseRegisterTests(), SigRegisterTests(), SMTPParserRegisterTests(), SSHParserRegisterTests(), StatsRegisterTests(), StreamingBufferRegisterTests(), StreamTcpInlineRegisterTests(), StreamTcpListRegisterTests(), StreamTcpReassembleRegisterTests(), StreamTcpRegisterTests(), StreamTcpSackRegisterTests(), StreamTcpUtilRegisterTests(), ThreadingAffinityRegisterTests(), ThreadMacrosRegisterTests(), TlsExpiredRegisterTests(), TlsNotAfterRegisterTests(), TlsNotBeforeRegisterTests(), TlsValidRegisterTests(), TmqhFlowRegisterTests(), UTHRegisterTests(), UtilActionRegisterTests(), UtilCIDRTests(), UtilMiscRegisterTests(), UtilSpmSearchRegistertests(), and UtRunSelftest().
void UtRunModeRegister | ( | void | ) |
Definition at line 283 of file util-unittest.c.
References RUNMODE_UNITTEST, and RunModeRegisterNewRunMode().
Referenced by RunModeRegisterRunModes().
int UtRunSelftest | ( | const char * | regex_arg | ) |
Run self tests.
regex_arg | The regular expression |
0 | all successful |
Definition at line 321 of file util-unittest.c.
References regex_arg, UtCleanup(), UtInitialize(), UtRegisterTest(), and UtRunTests().
Referenced by RunUnittests().
uint32_t UtRunTests | ( | const char * | regex_arg | ) |
Run all registered unittests.
regex_arg | The regular expression |
0 | all successful |
result | number of tests that failed |
Definition at line 188 of file util-unittest.c.
References FlowGetMemuse(), UtTest_::name, UtTest_::next, regex_arg, SCLogInfo, StreamTcpInitMemuse(), StreamTcpMemuseCounter(), StreamTcpReassembleInitMemuse(), StreamTcpReassembleMemuseGlobalCounter(), UtTest_::TestFn, TimeModeSetOffline(), TimeSetToCurrentTime(), and unittests_fatal.
Referenced by RunUnittests(), and UtRunSelftest().
int unittests_fatal = 0 |
Definition at line 52 of file util-unittest.c.
Referenced by SCParseCommandLine(), and UtRunTests().
|
extern |
Definition at line 52 of file util-unittest.c.
Referenced by SCParseCommandLine(), and UtRunTests().