diff --git a/src/util-unittest-helper.c b/src/util-unittest-helper.c index 47c67c0b67..a2baf67ee2 100644 --- a/src/util-unittest-helper.c +++ b/src/util-unittest-helper.c @@ -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 */ diff --git a/src/util-unittest-helper.h b/src/util-unittest-helper.h index 7d463359a7..8ce2a4653a 100644 --- a/src/util-unittest-helper.h +++ b/src/util-unittest-helper.h @@ -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);