aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-12 18:47:09 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-28 23:51:24 +0100
commitb27b352e937dd0760da1e7fb05f9207be05702b8 (patch)
treedf0a1dc555ee1ada807e51260de918dcf6f53370 /tests
parent0a1400fc8311268d0a66bb20e0620e546e8d11c8 (diff)
stats: Use a global index for stat item values
Currently each stat item has a separate index value which basically counts each single value added to the item and which can be used by a reporter to get all new values that have not been reported yet. The drawback is, that such an index must be stored for each stat item. This commit introduces a global index which is incremented for each new stat item value. This index is then stored together with the item value. So a single stored index per reporter is sufficient to make sure that only new values are reported. Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests')
-rw-r--r--tests/stats/stats_test.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index b4143853..9da49a4f 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -91,7 +91,7 @@ static void stat_test(void)
OSMO_ASSERT(value == 1);
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1);
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
@@ -102,11 +102,11 @@ static void stat_test(void)
stat_item_set(statg->items[TEST_B_ITEM], 1000 + i);
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == i);
rc = stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + i);
}
@@ -119,20 +119,20 @@ static void stat_test(void)
stat_item_set(statg->items[TEST_B_ITEM], 1000 + i);
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == i-1);
rc = stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + i-1);
}
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 64);
rc = stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + 64);
/* Overrun FIFOs */
@@ -142,29 +142,29 @@ static void stat_test(void)
}
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
- OSMO_ASSERT(rc == 93 - 65 + 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 93);
for (i = 94; i <= 96; i++) {
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == i);
}
rc = stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
- OSMO_ASSERT(rc == 90 - 65 + 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + 90);
for (i = 91; i <= 96; i++) {
rc = stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + i);
}
- /* Test Discard */
+ /* Test Discard (single item) */
stat_item_set(statg->items[TEST_A_ITEM], 97);
rc = stat_item_discard(statg->items[TEST_A_ITEM], &rd_a);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
rc = stat_item_discard(statg->items[TEST_A_ITEM], &rd_a);
OSMO_ASSERT(rc == 0);
@@ -174,12 +174,27 @@ static void stat_test(void)
stat_item_set(statg->items[TEST_A_ITEM], 98);
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
- OSMO_ASSERT(rc == 1);
+ OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 98);
rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
OSMO_ASSERT(rc == 0);
+ /* Test Discard (all items) */
+ stat_item_set(statg->items[TEST_A_ITEM], 99);
+ stat_item_set(statg->items[TEST_A_ITEM], 100);
+ stat_item_set(statg->items[TEST_A_ITEM], 101);
+ stat_item_set(statg->items[TEST_B_ITEM], 99);
+ stat_item_set(statg->items[TEST_B_ITEM], 100);
+
+ rc = stat_item_discard_all(&rd_a);
+ rc = stat_item_discard_all(&rd_b);
+
+ rc = stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ OSMO_ASSERT(rc == 0);
+ rc = stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
+ OSMO_ASSERT(rc == 0);
+
stat_item_group_free(statg);
sgrp2 = stat_item_get_group_by_name_idx("test.one", 0);