aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2021-03-26 11:34:34 +0100
committerOliver Smith <osmith@sysmocom.de>2021-04-06 11:27:34 +0200
commitd3490bc442ec68d300bbb96b419d25c25de0f01e (patch)
tree0fb8dc37368ffa545a5a62e9d36512a6532e99d4 /tests
parent8bd63b667e64ac8b91b33b7845967ddaf2628c64 (diff)
stat_item: make next_id argument name consistent
Let osmo_stat_item_get_next, osmo_stat_item_discard, osmo_stat_item_discard_all consistently refer to their next_id arg as such (and not idx or next_idx). It refers to an ID (item->values[i].id), not an index (item->values[i]), and it is always the next one, never the current one. Do the same change for _index/_idx variables in stats.c, which are used as arguments to these functions. Replace rd_ with next_id_ in stats_test.c, too. Related: OS#5088 Change-Id: I5dd566b08dff7174d1790f49abd2d6ac020e120e
Diffstat (limited to 'tests')
-rw-r--r--tests/stats/stats_test.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index 707f606f..e5f7f20f 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -90,8 +90,8 @@ static void stat_test(void)
const struct osmo_stat_item *sitem1, *sitem2;
int rc;
int32_t value;
- int32_t rd_a = 0;
- int32_t rd_b = 0;
+ int32_t next_id_a = 0;
+ int32_t next_id_b = 0;
int i;
OSMO_ASSERT(statg != NULL);
@@ -120,7 +120,7 @@ static void stat_test(void)
value = osmo_stat_item_get_last(statg->items[TEST_A_ITEM]);
OSMO_ASSERT(value == -1);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc == 0);
osmo_stat_item_set(statg->items[TEST_A_ITEM], 1);
@@ -128,39 +128,39 @@ static void stat_test(void)
value = osmo_stat_item_get_last(statg->items[TEST_A_ITEM]);
OSMO_ASSERT(value == 1);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc == 0);
for (i = 2; i <= 32; i++) {
osmo_stat_item_set(statg->items[TEST_A_ITEM], i);
osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == i);
- rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + i);
}
/* check if dec & inc is working */
osmo_stat_item_set(statg->items[TEST_A_ITEM], 42);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 42);
osmo_stat_item_dec(statg->items[TEST_A_ITEM], 21);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 21);
osmo_stat_item_inc(statg->items[TEST_A_ITEM], 21);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 42);
@@ -172,20 +172,20 @@ static void stat_test(void)
osmo_stat_item_set(statg->items[TEST_A_ITEM], i);
osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == i-1);
- rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + i-1);
}
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 64);
- rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + 64);
@@ -195,43 +195,43 @@ static void stat_test(void)
osmo_stat_item_set(statg->items[TEST_B_ITEM], 1000 + i);
}
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 93);
for (i = 94; i <= 96; i++) {
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == i);
}
- rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + 90);
for (i = 91; i <= 96; i++) {
- rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 1000 + i);
}
/* Test Discard (single item) */
osmo_stat_item_set(statg->items[TEST_A_ITEM], 97);
- rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &rd_a);
+ rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &next_id_a);
OSMO_ASSERT(rc > 0);
- rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &rd_a);
+ rc = osmo_stat_item_discard(statg->items[TEST_A_ITEM], &next_id_a);
OSMO_ASSERT(rc == 0);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc == 0);
osmo_stat_item_set(statg->items[TEST_A_ITEM], 98);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc > 0);
OSMO_ASSERT(value == 98);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc == 0);
/* Test Discard (all items) */
@@ -241,12 +241,12 @@ static void stat_test(void)
osmo_stat_item_set(statg->items[TEST_B_ITEM], 99);
osmo_stat_item_set(statg->items[TEST_B_ITEM], 100);
- rc = osmo_stat_item_discard_all(&rd_a);
- rc = osmo_stat_item_discard_all(&rd_b);
+ rc = osmo_stat_item_discard_all(&next_id_a);
+ rc = osmo_stat_item_discard_all(&next_id_b);
- rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &rd_a, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_A_ITEM], &next_id_a, &value);
OSMO_ASSERT(rc == 0);
- rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &rd_b, &value);
+ rc = osmo_stat_item_get_next(statg->items[TEST_B_ITEM], &next_id_b, &value);
OSMO_ASSERT(rc == 0);
osmo_stat_item_group_free(statg);