aboutsummaryrefslogtreecommitdiffstats
path: root/tests/subscr
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-09-15 01:03:58 +0000
committerNeels Hofmeyr <neels@hofmeyr.de>2020-10-07 11:40:12 +0000
commit86a1dca5c765f3abdd3b01f4ba49217dbc0f34e0 (patch)
tree0023b9f53544b7a73386a0b030a9d56a6e866338 /tests/subscr
parentd4946b22f7607d93095386e418ff29e456c243a2 (diff)
introduce osmo_use_count for bsc_subscr
During LCS development, I'm getting use count bugs and would like to see use token strings to figure it out. Change-Id: I29bf60059d4cf7bb99a00753e6cdc149baf95f94
Diffstat (limited to 'tests/subscr')
-rw-r--r--tests/subscr/bsc_subscr_test.c34
-rw-r--r--tests/subscr/bsc_subscr_test.err40
2 files changed, 38 insertions, 36 deletions
diff --git a/tests/subscr/bsc_subscr_test.c b/tests/subscr/bsc_subscr_test.c
index 3c94b8662..fcaea63eb 100644
--- a/tests/subscr/bsc_subscr_test.c
+++ b/tests/subscr/bsc_subscr_test.c
@@ -37,16 +37,18 @@ struct llist_head *bsc_subscribers;
OSMO_ASSERT((val) expect_op); \
} while (0);
+#define BSUB_USE "test"
+
static void assert_bsc_subscr(const struct bsc_subscr *bsub, const char *imsi)
{
struct bsc_subscr *sfound;
OSMO_ASSERT(bsub);
OSMO_ASSERT(strcmp(bsub->imsi, imsi) == 0);
- sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi);
+ sfound = bsc_subscr_find_by_imsi(bsc_subscribers, imsi, BSUB_USE);
OSMO_ASSERT(sfound == bsub);
- bsc_subscr_put(sfound);
+ bsc_subscr_put(sfound, BSUB_USE);
}
static void test_bsc_subscr(void)
@@ -60,23 +62,23 @@ static void test_bsc_subscr(void)
/* Check for emptiness */
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d");
- OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
- OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
- OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1, BSUB_USE) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2, BSUB_USE) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3, BSUB_USE) == NULL);
/* Allocate entry 1 */
- s1 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi1);
+ s1 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi1, BSUB_USE);
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
assert_bsc_subscr(s1, imsi1);
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
- OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2, BSUB_USE) == NULL);
/* Allocate entry 2 */
- s2 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi2);
+ s2 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi2, BSUB_USE);
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d");
/* Allocate entry 3 */
- s3 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi3);
+ s3 = bsc_subscr_find_or_create_by_imsi(bsc_subscribers, imsi3, BSUB_USE);
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 3, "%d");
/* Check entries */
@@ -85,27 +87,27 @@ static void test_bsc_subscr(void)
assert_bsc_subscr(s3, imsi3);
/* Free entry 1 */
- bsc_subscr_put(s1);
+ bsc_subscr_put(s1, BSUB_USE);
s1 = NULL;
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 2, "%d");
- OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1, BSUB_USE) == NULL);
assert_bsc_subscr(s2, imsi2);
assert_bsc_subscr(s3, imsi3);
/* Free entry 2 */
- bsc_subscr_put(s2);
+ bsc_subscr_put(s2, BSUB_USE);
s2 = NULL;
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 1, "%d");
- OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1) == NULL);
- OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi1, BSUB_USE) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi2, BSUB_USE) == NULL);
assert_bsc_subscr(s3, imsi3);
/* Free entry 3 */
- bsc_subscr_put(s3);
+ bsc_subscr_put(s3, BSUB_USE);
s3 = NULL;
VERBOSE_ASSERT(llist_count(bsc_subscribers), == 0, "%d");
- OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3) == NULL);
+ OSMO_ASSERT(bsc_subscr_find_by_imsi(bsc_subscribers, imsi3, BSUB_USE) == NULL);
OSMO_ASSERT(llist_empty(bsc_subscribers));
}
diff --git a/tests/subscr/bsc_subscr_test.err b/tests/subscr/bsc_subscr_test.err
index afc8bf778..a78e7576a 100644
--- a/tests/subscr/bsc_subscr_test.err
+++ b/tests/subscr/bsc_subscr_test.err
@@ -1,20 +1,20 @@
-DREF BSC subscr IMSI:1234567890 usage increases to: 1
-DREF BSC subscr IMSI:1234567890 usage increases to: 2
-DREF BSC subscr IMSI:1234567890 usage decreases to: 1
-DREF BSC subscr IMSI:9876543210 usage increases to: 1
-DREF BSC subscr IMSI:5656565656 usage increases to: 1
-DREF BSC subscr IMSI:1234567890 usage increases to: 2
-DREF BSC subscr IMSI:1234567890 usage decreases to: 1
-DREF BSC subscr IMSI:9876543210 usage increases to: 2
-DREF BSC subscr IMSI:9876543210 usage decreases to: 1
-DREF BSC subscr IMSI:5656565656 usage increases to: 2
-DREF BSC subscr IMSI:5656565656 usage decreases to: 1
-DREF BSC subscr IMSI:1234567890 usage decreases to: 0
-DREF BSC subscr IMSI:9876543210 usage increases to: 2
-DREF BSC subscr IMSI:9876543210 usage decreases to: 1
-DREF BSC subscr IMSI:5656565656 usage increases to: 2
-DREF BSC subscr IMSI:5656565656 usage decreases to: 1
-DREF BSC subscr IMSI:9876543210 usage decreases to: 0
-DREF BSC subscr IMSI:5656565656 usage increases to: 2
-DREF BSC subscr IMSI:5656565656 usage decreases to: 1
-DREF BSC subscr IMSI:5656565656 usage decreases to: 0
+DREF BSC subscr IMSI:1234567890: + test: now used by 1 (test)
+DREF BSC subscr IMSI:1234567890: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:1234567890: - test: now used by 1 (test)
+DREF BSC subscr IMSI:9876543210: + test: now used by 1 (test)
+DREF BSC subscr IMSI:5656565656: + test: now used by 1 (test)
+DREF BSC subscr IMSI:1234567890: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:1234567890: - test: now used by 1 (test)
+DREF BSC subscr IMSI:9876543210: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:9876543210: - test: now used by 1 (test)
+DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
+DREF BSC subscr IMSI:1234567890: - test: now used by 0 (-)
+DREF BSC subscr IMSI:9876543210: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:9876543210: - test: now used by 1 (test)
+DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
+DREF BSC subscr IMSI:9876543210: - test: now used by 0 (-)
+DREF BSC subscr IMSI:5656565656: + test: now used by 2 (2*test)
+DREF BSC subscr IMSI:5656565656: - test: now used by 1 (test)
+DREF BSC subscr IMSI:5656565656: - test: now used by 0 (-)