]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream/tests: minor cleanups 5751/head
authorVictor Julien <victor@inliniac.net>
Wed, 20 Jan 2021 07:40:04 +0000 (08:40 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 20 Jan 2021 07:44:22 +0000 (08:44 +0100)
src/tests/stream-tcp.c

index 30b188dd5e81a5e8a18317ebf4384e87efa5472e..1d01a83d4488fde922023cb926f51508a3b85809 100644 (file)
 static int StreamTcpTest01(void)
 {
     StreamTcpThread stt;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     FLOW_INITIALIZE(&f);
     p->flow = &f;
@@ -88,7 +86,7 @@ end:
 
 static int StreamTcpTest02(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(unlikely(p == NULL));
     Flow f;
     ThreadVars tv;
@@ -97,7 +95,6 @@ static int StreamTcpTest02(void)
     TCPHdr tcph;
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(pq));
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -174,14 +171,12 @@ static int StreamTcpTest02(void)
 
 static int StreamTcpTest03(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(pq));
     memset(&f, 0, sizeof(Flow));
@@ -250,14 +245,12 @@ end:
 
 static int StreamTcpTest04(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(pq));
     memset(&f, 0, sizeof(Flow));
@@ -319,15 +312,13 @@ end:
 
 static int StreamTcpTest05(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
     uint8_t payload[4];
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -419,15 +410,13 @@ end:
 
 static int StreamTcpTest06(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     TcpSession ssn;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -482,7 +471,7 @@ end:
 
 static int StreamTcpTest07(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(unlikely(p == NULL));
     Flow f;
     ThreadVars tv;
@@ -491,7 +480,6 @@ static int StreamTcpTest07(void)
     uint8_t payload[1] = { 0x42 };
     PacketQueueNoLock pq;
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
@@ -544,7 +532,7 @@ static int StreamTcpTest07(void)
 
 static int StreamTcpTest08(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(unlikely(p == NULL));
     Flow f;
     ThreadVars tv;
@@ -552,7 +540,6 @@ static int StreamTcpTest08(void)
     TCPHdr tcph;
     uint8_t payload[1] = { 0x42 };
 
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -607,7 +594,7 @@ static int StreamTcpTest08(void)
 
 static int StreamTcpTest09(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(unlikely(p == NULL));
     Flow f;
     ThreadVars tv;
@@ -615,7 +602,6 @@ static int StreamTcpTest09(void)
     TCPHdr tcph;
     uint8_t payload[1] = { 0x42 };
 
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -678,14 +664,13 @@ static int StreamTcpTest09(void)
 
 static int StreamTcpTest10(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(unlikely(p == NULL));
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
     uint8_t payload[4];
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -757,14 +742,13 @@ static int StreamTcpTest10(void)
 
 static int StreamTcpTest11(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(unlikely(p == NULL));
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
     uint8_t payload[4];
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -837,15 +821,13 @@ static int StreamTcpTest11(void)
 
 static int StreamTcpTest12(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
     uint8_t payload[4];
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -933,15 +915,13 @@ end:
 
 static int StreamTcpTest13(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
     uint8_t payload[4];
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -1130,9 +1110,8 @@ end:
 
 static int StreamTcpTest14(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
@@ -1145,7 +1124,6 @@ static int StreamTcpTest14(void)
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -1183,7 +1161,6 @@ static int StreamTcpTest14(void)
     p->payload = payload;
     p->payload_len = 3;
 
-    FLOWLOCK_WRLOCK(&f);
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
@@ -1280,7 +1257,6 @@ static int StreamTcpTest14(void)
 end:
     ConfDeInit();
     ConfRestoreContextBackup();
-    FLOWLOCK_UNLOCK(&f);
     SCFree(p);
     FLOW_DESTROY(&f);
     StreamTcpUTDeinit(stt.ra_ctx);
@@ -1297,14 +1273,12 @@ end:
 static int StreamTcp4WHSTest01(void)
 {
     int ret = 0;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -1379,14 +1353,12 @@ end:
 static int StreamTcp4WHSTest02(void)
 {
     int ret = 0;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -1450,13 +1422,12 @@ end:
 static int StreamTcp4WHSTest03(void)
 {
     int ret = 0;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(unlikely(p == NULL));
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
     TCPHdr tcph;
-    memset(p, 0, SIZE_OF_PACKET);
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
@@ -1529,9 +1500,8 @@ end:
 
 static int StreamTcpTest15(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
@@ -1544,7 +1514,6 @@ static int StreamTcpTest15(void)
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -1693,9 +1662,8 @@ end:
 
 static int StreamTcpTest16(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
@@ -1708,7 +1676,6 @@ static int StreamTcpTest16(void)
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -1746,7 +1713,6 @@ static int StreamTcpTest16(void)
     p->payload = payload;
     p->payload_len = 3;
 
-    FLOWLOCK_WRLOCK(&f);
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
@@ -1843,7 +1809,6 @@ static int StreamTcpTest16(void)
 end:
     ConfDeInit();
     ConfRestoreContextBackup();
-    FLOWLOCK_UNLOCK(&f);
     SCFree(p);
     FLOW_DESTROY(&f);
     StreamTcpUTDeinit(stt.ra_ctx);
@@ -1860,9 +1825,8 @@ end:
 
 static int StreamTcpTest17(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
@@ -1875,7 +1839,6 @@ static int StreamTcpTest17(void)
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -1913,7 +1876,6 @@ static int StreamTcpTest17(void)
     p->payload = payload;
     p->payload_len = 3;
 
-    FLOWLOCK_WRLOCK(&f);
     if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
         goto end;
 
@@ -2010,7 +1972,6 @@ static int StreamTcpTest17(void)
 end:
     ConfDeInit();
     ConfRestoreContextBackup();
-    FLOWLOCK_UNLOCK(&f);
     SCFree(p);
     FLOW_DESTROY(&f);
     StreamTcpUTDeinit(stt.ra_ctx);
@@ -2026,15 +1987,13 @@ static int StreamTcpTest18(void)
     char os_policy_name[10] = "windows";
     const char *ip_addr;
     TcpStream stream;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     IPV4Hdr ipv4h;
     int ret = 0;
 
     memset(&addr, 0, sizeof(addr));
     memset(&stream, 0, sizeof(stream));
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&ipv4h, 0, sizeof(ipv4h));
 
     StreamTcpUTInit(&stt.ra_ctx);
@@ -2075,15 +2034,13 @@ static int StreamTcpTest19(void)
     char os_policy_name[10] = "windows";
     const char *ip_addr;
     TcpStream stream;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     IPV4Hdr ipv4h;
     int ret = 0;
 
     memset(&addr, 0, sizeof(addr));
     memset(&stream, 0, sizeof(stream));
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&ipv4h, 0, sizeof(ipv4h));
 
     StreamTcpUTInit(&stt.ra_ctx);
@@ -2127,15 +2084,13 @@ static int StreamTcpTest20(void)
     char os_policy_name[10] = "linux";
     const char *ip_addr;
     TcpStream stream;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     IPV4Hdr ipv4h;
     int ret = 0;
 
     memset(&addr, 0, sizeof(addr));
     memset(&stream, 0, sizeof(stream));
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&ipv4h, 0, sizeof(ipv4h));
 
     StreamTcpUTInit(&stt.ra_ctx);
@@ -2179,15 +2134,13 @@ static int StreamTcpTest21(void)
     char os_policy_name[10] = "linux";
     const char *ip_addr;
     TcpStream stream;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     IPV4Hdr ipv4h;
     int ret = 0;
 
     memset(&addr, 0, sizeof(addr));
     memset(&stream, 0, sizeof(stream));
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&ipv4h, 0, sizeof(ipv4h));
 
     StreamTcpUTInit(&stt.ra_ctx);
@@ -2231,15 +2184,13 @@ static int StreamTcpTest22(void)
     char os_policy_name[10] = "windows";
     const char *ip_addr;
     TcpStream stream;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     IPV4Hdr ipv4h;
     int ret = 0;
 
     memset(&addr, 0, sizeof(addr));
     memset(&stream, 0, sizeof(stream));
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&ipv4h, 0, sizeof(ipv4h));
 
     StreamTcpUTInit(&stt.ra_ctx);
@@ -2286,11 +2237,10 @@ static int StreamTcpTest23(void)
     ThreadVars tv;
     PacketQueueNoLock pq;
 
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(p == NULL);
 
     memset(&pq, 0, sizeof(PacketQueueNoLock));
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tcph, 0, sizeof(TCPHdr));
     memset(&tv, 0, sizeof(ThreadVars));
@@ -2346,7 +2296,7 @@ static int StreamTcpTest24(void)
 {
     StreamTcpThread stt;
     TcpSession ssn;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
     FAIL_IF(p == NULL);
     Flow f;
     TCPHdr tcph;
@@ -2359,7 +2309,6 @@ static int StreamTcpTest24(void)
     StreamTcpUTInit(&stt.ra_ctx);
     StreamTcpUTSetupSession(&ssn);
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tcph, 0, sizeof(TCPHdr));
     FLOW_INITIALIZE(&f);
@@ -2414,9 +2363,8 @@ static int StreamTcpTest24(void)
  */
 static int StreamTcpTest25(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
@@ -2426,7 +2374,6 @@ static int StreamTcpTest25(void)
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -2507,9 +2454,8 @@ end:
  */
 static int StreamTcpTest26(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
@@ -2519,7 +2465,6 @@ static int StreamTcpTest26(void)
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -2601,9 +2546,8 @@ end:
  */
 static int StreamTcpTest27(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
@@ -2613,7 +2557,6 @@ static int StreamTcpTest27(void)
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -3572,9 +3515,8 @@ end:
  */
 static int StreamTcpTest37(void)
 {
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     Flow f;
     ThreadVars tv;
     StreamTcpThread stt;
@@ -3584,7 +3526,6 @@ static int StreamTcpTest37(void)
     PacketQueueNoLock pq;
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    memset(p, 0, SIZE_OF_PACKET);
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
     memset(&stt, 0, sizeof(StreamTcpThread));
@@ -3705,10 +3646,8 @@ static int StreamTcpTest38(void)
     memset(&tcph, 0, sizeof(TCPHdr));
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
-    memset(p, 0, SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
 
     FLOW_INITIALIZE(&f);
     p->flow = &f;
@@ -3860,10 +3799,8 @@ static int StreamTcpTest39(void)
     memset(&tcph, 0, sizeof(TCPHdr));
     memset(&pq, 0, sizeof(PacketQueueNoLock));
 
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
-    if (unlikely(p == NULL))
-        return 0;
-    memset(p, 0, SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
 
     FLOW_INITIALIZE(&f);
     p->flow = &f;
@@ -3982,13 +3919,10 @@ static int StreamTcpTest42(void)
     StreamTcpThread stt;
     TCPHdr tcph;
     PacketQueueNoLock pq;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     TcpSession *ssn;
 
-    if (unlikely(p == NULL))
-        return 0;
-    memset(p, 0, SIZE_OF_PACKET);
-
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
@@ -4072,13 +4006,10 @@ static int StreamTcpTest43(void)
     StreamTcpThread stt;
     TCPHdr tcph;
     PacketQueueNoLock pq;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     TcpSession *ssn;
 
-    if (unlikely(p == NULL))
-        return 0;
-    memset(p, 0, SIZE_OF_PACKET);
-
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
@@ -4162,13 +4093,10 @@ static int StreamTcpTest44(void)
     StreamTcpThread stt;
     TCPHdr tcph;
     PacketQueueNoLock pq;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     TcpSession *ssn;
 
-    if (unlikely(p == NULL))
-        return 0;
-    memset(p, 0, SIZE_OF_PACKET);
-
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));
@@ -4248,13 +4176,10 @@ static int StreamTcpTest45(void)
     StreamTcpThread stt;
     TCPHdr tcph;
     PacketQueueNoLock pq;
-    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    Packet *p = PacketGetFromAlloc();
+    FAIL_IF_NULL(p);
     TcpSession *ssn;
 
-    if (unlikely(p == NULL))
-        return 0;
-    memset(p, 0, SIZE_OF_PACKET);
-
     memset(&pq, 0, sizeof(PacketQueueNoLock));
     memset(&f, 0, sizeof(Flow));
     memset(&tv, 0, sizeof(ThreadVars));