detect: unittest guards for ut only function

pull/8042/head
Victor Julien 2 years ago
parent 60285a629f
commit 410acf226f

@ -126,6 +126,7 @@ static int PacketAlertHandle(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det
SCReturnInt(1);
}
#ifdef UNITTESTS
/**
* \brief Check if a certain sid alerted, this is used in the test functions
*
@ -136,19 +137,17 @@ static int PacketAlertHandle(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det
*/
int PacketAlertCheck(Packet *p, uint32_t sid)
{
uint16_t i = 0;
int match = 0;
for (i = 0; i < p->alerts.cnt; i++) {
if (p->alerts.alerts[i].s == NULL)
continue;
for (uint16_t i = 0; i < p->alerts.cnt; i++) {
BUG_ON(p->alerts.alerts[i].s == NULL);
if (p->alerts.alerts[i].s->id == sid)
match++;
}
return match;
}
#endif
static inline void RuleActionToFlow(const uint8_t action, Flow *f)
{

@ -33,7 +33,9 @@ void AlertQueueFree(DetectEngineThreadCtx *det_ctx);
void AlertQueueAppend(DetectEngineThreadCtx *det_ctx, const Signature *s, Packet *p, uint64_t tx_id,
uint8_t alert_flags);
void PacketAlertFinalize(DetectEngineCtx *, DetectEngineThreadCtx *, Packet *);
#ifdef UNITTESTS
int PacketAlertCheck(Packet *, uint32_t);
#endif
void PacketAlertTagInit(void);
void DetectEngineAlertRegisterTests(void);

Loading…
Cancel
Save