unittests: add signature parse test helper

pull/3632/head
Victor Julien 7 years ago
parent 705d3b6130
commit 42d22ddb2a

@ -925,6 +925,24 @@ uint32_t UTHBuildPacketOfFlows(uint32_t start, uint32_t end, uint8_t dir)
return i;
}
/** \brief parser a sig and see if the expected result is correct */
int UTHParseSignature(const char *str, bool expect)
{
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx);
de_ctx->flags |= DE_QUIET;
Signature *s = DetectEngineAppendSig(de_ctx, str);
if (expect)
FAIL_IF_NULL(s);
else
FAIL_IF_NOT_NULL(s);
DetectEngineCtxFree(de_ctx);
PASS;
}
/*
* unittests for the unittest helpers
*/

@ -60,6 +60,8 @@ int UTHGenericTest(Packet **, int, const char **, uint32_t *, uint32_t *, int);
uint32_t UTHBuildPacketOfFlows(uint32_t, uint32_t, uint8_t);
Packet *UTHBuildPacketIPV6Real(uint8_t *, uint16_t , uint8_t ipproto, const char *, const char *,
uint16_t , uint16_t );
int UTHParseSignature(const char *str, bool expect);
#endif
void UTHRegisterTests(void);

Loading…
Cancel
Save