applayer: convert to FAIL/PASS API

pull/5646/head
Shivani Bhardwaj 5 years ago committed by Victor Julien
parent bfd956ce67
commit fb311e3d9d

@ -1792,7 +1792,6 @@ static int AppLayerParserTest01(void)
{ {
AppLayerParserBackupParserTable(); AppLayerParserBackupParserTable();
int result = 0;
Flow *f = NULL; Flow *f = NULL;
uint8_t testbuf[] = { 0x11 }; uint8_t testbuf[] = { 0x11 };
uint32_t testlen = sizeof(testbuf); uint32_t testlen = sizeof(testbuf);
@ -1811,37 +1810,24 @@ static int AppLayerParserTest01(void)
AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_TEST, TestGetTxCnt); AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_TEST, TestGetTxCnt);
f = UTHBuildFlow(AF_INET, "1.2.3.4", "4.3.2.1", 20, 40); f = UTHBuildFlow(AF_INET, "1.2.3.4", "4.3.2.1", 20, 40);
if (f == NULL) FAIL_IF_NULL(f);
goto end;
f->protoctx = &ssn; f->protoctx = &ssn;
f->alproto = ALPROTO_TEST; f->alproto = ALPROTO_TEST;
f->proto = IPPROTO_TCP; f->proto = IPPROTO_TCP;
StreamTcpInitConfig(TRUE); StreamTcpInitConfig(TRUE);
FLOWLOCK_WRLOCK(f);
int r = AppLayerParserParse(NULL, alp_tctx, f, ALPROTO_TEST, int r = AppLayerParserParse(NULL, alp_tctx, f, ALPROTO_TEST,
STREAM_TOSERVER | STREAM_EOF, testbuf, STREAM_TOSERVER | STREAM_EOF, testbuf,
testlen); testlen);
if (r != -1) { FAIL_IF(r != -1);
printf("returned %" PRId32 ", expected -1: ", r);
FLOWLOCK_UNLOCK(f);
goto end;
}
FLOWLOCK_UNLOCK(f);
if (!(ssn.flags & STREAMTCP_FLAG_APP_LAYER_DISABLED)) { FAIL_IF(!(ssn.flags & STREAMTCP_FLAG_APP_LAYER_DISABLED));
printf("flag should have been set, but is not: ");
goto end;
}
result = 1;
end:
AppLayerParserRestoreParserTable(); AppLayerParserRestoreParserTable();
StreamTcpFreeConfig(TRUE); StreamTcpFreeConfig(TRUE);
UTHFreeFlow(f); UTHFreeFlow(f);
return result; PASS;
} }
/** /**
@ -1852,7 +1838,6 @@ static int AppLayerParserTest02(void)
{ {
AppLayerParserBackupParserTable(); AppLayerParserBackupParserTable();
int result = 1;
Flow *f = NULL; Flow *f = NULL;
uint8_t testbuf[] = { 0x11 }; uint8_t testbuf[] = { 0x11 };
uint32_t testlen = sizeof(testbuf); uint32_t testlen = sizeof(testbuf);
@ -1868,31 +1853,22 @@ static int AppLayerParserTest02(void)
AppLayerParserRegisterGetTxCnt(IPPROTO_UDP, ALPROTO_TEST, TestGetTxCnt); AppLayerParserRegisterGetTxCnt(IPPROTO_UDP, ALPROTO_TEST, TestGetTxCnt);
f = UTHBuildFlow(AF_INET, "1.2.3.4", "4.3.2.1", 20, 40); f = UTHBuildFlow(AF_INET, "1.2.3.4", "4.3.2.1", 20, 40);
if (f == NULL) FAIL_IF_NULL(f);
goto end;
f->alproto = ALPROTO_TEST; f->alproto = ALPROTO_TEST;
f->proto = IPPROTO_UDP; f->proto = IPPROTO_UDP;
f->protomap = FlowGetProtoMapping(f->proto); f->protomap = FlowGetProtoMapping(f->proto);
StreamTcpInitConfig(TRUE); StreamTcpInitConfig(TRUE);
FLOWLOCK_WRLOCK(f);
int r = AppLayerParserParse(NULL, alp_tctx, f, ALPROTO_TEST, int r = AppLayerParserParse(NULL, alp_tctx, f, ALPROTO_TEST,
STREAM_TOSERVER | STREAM_EOF, testbuf, STREAM_TOSERVER | STREAM_EOF, testbuf,
testlen); testlen);
if (r != -1) { FAIL_IF(r != -1);
printf("returned %" PRId32 ", expected -1: \n", r);
result = 0;
FLOWLOCK_UNLOCK(f);
goto end;
}
FLOWLOCK_UNLOCK(f);
end:
AppLayerParserRestoreParserTable(); AppLayerParserRestoreParserTable();
StreamTcpFreeConfig(TRUE); StreamTcpFreeConfig(TRUE);
UTHFreeFlow(f); UTHFreeFlow(f);
return result; PASS;
} }

Loading…
Cancel
Save