*/
static int DetectWindowTestParse01 (void)
{
- int result = 0;
DetectWindowData *wd = NULL;
wd = DetectWindowParse(NULL, "35402");
- if (wd != NULL &&wd->size==35402) {
- DetectWindowFree(NULL, wd);
- result = 1;
- }
+ FAIL_IF_NULL(wd);
+ FAIL_IF_NOT(wd->size == 35402);
- return result;
+ DetectWindowFree(NULL, wd);
+ PASS;
}
/**
*/
static int DetectWindowTestParse02 (void)
{
- int result = 0;
DetectWindowData *wd = NULL;
wd = DetectWindowParse(NULL, "!35402");
- if (wd != NULL) {
- if (wd->negated == 1 && wd->size==35402) {
- result = 1;
- } else {
- printf("expected wd->negated=1 and wd->size=35402\n");
- }
- DetectWindowFree(NULL, wd);
- }
+ FAIL_IF_NULL(wd);
+ FAIL_IF_NOT(wd->negated == 1);
+ FAIL_IF_NOT(wd->size == 35402);
- return result;
+ DetectWindowFree(NULL, wd);
+ PASS;
}
/**
*/
static int DetectWindowTestParse03 (void)
{
- int result = 0;
DetectWindowData *wd = NULL;
wd = DetectWindowParse(NULL, "");
- if (wd == NULL) {
- result = 1;
- } else {
- printf("expected a NULL pointer (It was an empty string)\n");
- }
- DetectWindowFree(NULL, wd);
+ FAIL_IF_NOT_NULL(wd);
- return result;
+ DetectWindowFree(NULL, wd);
+ PASS;
}
/**
*/
static int DetectWindowTestParse04 (void)
{
- int result = 0;
DetectWindowData *wd = NULL;
wd = DetectWindowParse(NULL, "1235402");
- if (wd != NULL) {
- printf("expected a NULL pointer (It was exceeding the MAX window size)\n");
- DetectWindowFree(NULL, wd);
- }else
- result=1;
+ FAIL_IF_NOT_NULL(wd);
- return result;
+ DetectWindowFree(NULL, wd);
+ PASS;
}
/**
*/
static int DetectWindowTestPacket01 (void)
{
- int result = 0;
uint8_t *buf = (uint8_t *)"Hi all!";
uint16_t buflen = strlen((char *)buf);
Packet *p[3];
p[1] = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_TCP);
p[2] = UTHBuildPacket((uint8_t *)buf, buflen, IPPROTO_ICMP);
- if (p[0] == NULL || p[1] == NULL ||p[2] == NULL)
- goto end;
+ FAIL_IF(p[0] == NULL || p[1] == NULL || p[2] == NULL);
/* TCP wwindow = 40 */
p[0]->tcph->th_win = htons(40);
{0, 1},
/* packet 2 should not match */
{0, 0} };
- result = UTHGenericTest(p, 3, sigs, sid, (uint32_t *) results, 2);
+ FAIL_IF(UTHGenericTest(p, 3, sigs, sid, (uint32_t *)results, 2) == 0);
UTHFreePackets(p, 3);
-end:
- return result;
+ PASS;
}
/**