]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
counters: convert to FAIL/PASS API 5646/head 5648/head
authorShivani Bhardwaj <shivanib134@gmail.com>
Fri, 11 Sep 2020 15:12:22 +0000 (20:42 +0530)
committerVictor Julien <victor@inliniac.net>
Wed, 9 Dec 2020 14:24:15 +0000 (15:24 +0100)
src/counters.c

index b1c64f2cd9f18d4f806f0cad6019318b6e5a10e4..116d85ae9fb676c6475a4b7dc6e0e2b48a2f6bd2 100644 (file)
@@ -1338,9 +1338,11 @@ static int StatsTestCounterReg03(void)
 
     result = RegisterCounter("t1", "c1", &pctx);
 
+    FAIL_IF_NOT(result);
+
     StatsReleaseCounters(pctx.head);
 
-    return result;
+    PASS;
 }
 
 static int StatsTestCounterReg04(void)
@@ -1356,9 +1358,11 @@ static int StatsTestCounterReg04(void)
 
     result = RegisterCounter("t1", "c1", &pctx);
 
+    FAIL_IF_NOT(result);
+
     StatsReleaseCounters(pctx.head);
 
-    return result;
+    PASS;
 }
 
 static int StatsTestGetCntArray05(void)
@@ -1369,35 +1373,30 @@ static int StatsTestGetCntArray05(void)
     memset(&tv, 0, sizeof(ThreadVars));
 
     id = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
-    if (id != 1) {
-        printf("id %d: ", id);
-        return 0;
-    }
+    FAIL_IF(id != 1);
 
     int r = StatsGetAllCountersArray(NULL, &tv.perf_private_ctx);
-    return (r == -1) ? 1 : 0;
+    FAIL_IF_NOT(r == -1);
+    PASS;
 }
 
 static int StatsTestGetCntArray06(void)
 {
     ThreadVars tv;
     int id;
-    int result;
 
     memset(&tv, 0, sizeof(ThreadVars));
 
     id = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
-    if (id != 1)
-        return 0;
+    FAIL_IF(id != 1);
 
     int r = StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
-
-    result = (r == 0) ? 1  : 0;
+    FAIL_IF_NOT(r == 0);
 
     StatsReleaseCounters(tv.perf_public_ctx.head);
     StatsReleasePrivateThreadContext(&tv.perf_private_ctx);
 
-    return result;
+    PASS;
 }
 
 static int StatsTestCntArraySize07(void)
@@ -1432,7 +1431,6 @@ static int StatsTestUpdateCounter08(void)
     ThreadVars tv;
     StatsPrivateThreadContext *pca = NULL;
     int id;
-    int result;
 
     memset(&tv, 0, sizeof(ThreadVars));
 
@@ -1444,12 +1442,12 @@ static int StatsTestUpdateCounter08(void)
     StatsIncr(&tv, id);
     StatsAddUI64(&tv, id, 100);
 
-    result = pca->head[id].value;
+    FAIL_IF_NOT(pca->head[id].value == 101);
 
     StatsReleaseCounters(tv.perf_public_ctx.head);
     StatsReleasePrivateThreadContext(pca);
 
-    return result == 101;
+    PASS;
 }
 
 static int StatsTestUpdateCounter09(void)
@@ -1457,7 +1455,6 @@ static int StatsTestUpdateCounter09(void)
     ThreadVars tv;
     StatsPrivateThreadContext *pca = NULL;
     uint16_t id1, id2;
-    int result;
 
     memset(&tv, 0, sizeof(ThreadVars));
 
@@ -1473,12 +1470,12 @@ static int StatsTestUpdateCounter09(void)
     StatsIncr(&tv, id2);
     StatsAddUI64(&tv, id2, 100);
 
-    result = (pca->head[id1].value == 0) && (pca->head[id2].value == 101);
+    FAIL_IF_NOT((pca->head[id1].value == 0) && (pca->head[id2].value == 101));
 
     StatsReleaseCounters(tv.perf_public_ctx.head);
     StatsReleasePrivateThreadContext(pca);
 
-    return result;
+    PASS;
 }
 
 static int StatsTestUpdateGlobalCounter10(void)
@@ -1508,11 +1505,12 @@ static int StatsTestUpdateGlobalCounter10(void)
     result = (1 == tv.perf_public_ctx.head->value);
     result &= (100 == tv.perf_public_ctx.head->next->value);
     result &= (101 == tv.perf_public_ctx.head->next->next->value);
+    FAIL_IF_NOT(result);
 
     StatsReleaseCounters(tv.perf_public_ctx.head);
     StatsReleasePrivateThreadContext(pca);
 
-    return result;
+    PASS;
 }
 
 static int StatsTestCounterValues11(void)
@@ -1541,17 +1539,15 @@ static int StatsTestCounterValues11(void)
     StatsUpdateCounterArray(pca, &tv.perf_public_ctx);
 
     result &= (1 == tv.perf_public_ctx.head->value);
-
     result &= (256 == tv.perf_public_ctx.head->next->value);
-
     result &= (257 == tv.perf_public_ctx.head->next->next->value);
-
     result &= (16843024 == tv.perf_public_ctx.head->next->next->next->value);
+    FAIL_IF_NOT(result);
 
     StatsReleaseCounters(tv.perf_public_ctx.head);
     StatsReleasePrivateThreadContext(pca);
 
-    return result;
+    PASS;
 }
 
 #endif