diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/stats/stats_test.c | 43 | 
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);  | 
