summaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-01-13 11:46:32 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-18 18:29:13 +0100
commit058bc26e1bb1350c9077f99edd24887bb84bc8c5 (patch)
treed7e688ab04c2a07d31aaf80b78df268763ea4bc9 /openbsc/tests
parentc157ee7d2ccdb7524e76d25b22cb7eec8de9a656 (diff)
sgsn/test: Add checks and reports to detect subscr leakage
This commit adds talloc reports to log remaining NULL chunks after the terminates. It also adds explicit checks for empty subscriber lists. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index da1cb4b12..d6126523e 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -211,6 +211,25 @@ static void assert_subscr(const struct gsm_subscriber *subscr, const char *imsi)
OSMO_ASSERT(strcmp(subscr->imsi, imsi) == 0);
}
+static void show_subscrs(FILE *out)
+{
+ struct gsm_subscriber *subscr;
+
+ llist_for_each_entry(subscr, &active_subscribers, entry) {
+ fprintf(out, " Subscriber: %s, "
+ "use count: %d, keep: %d, timer: %d\n",
+ subscr->imsi, subscr->use_count, subscr->keep_in_ram,
+ osmo_timer_pending(&subscr->sgsn_data->timer));
+ }
+}
+
+static void assert_no_subscrs()
+{
+ show_subscrs(stdout);
+ fflush(stdout);
+ OSMO_ASSERT(llist_empty(&active_subscribers));
+}
+
static void test_subscriber(void)
{
struct gsm_subscriber *s1, *s2, *s3, *sfound;
@@ -911,6 +930,7 @@ static void test_gmm_attach_subscr(void)
test_gmm_attach(0);
cleanup_subscr_by_imsi("123456789012345");
+ assert_no_subscrs();
sgsn->cfg.auth_policy = saved_auth_policy;
subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
@@ -947,6 +967,7 @@ static void test_gmm_attach_subscr_fake_auth(void)
test_gmm_attach(0);
cleanup_subscr_by_imsi("123456789012345");
+ assert_no_subscrs();
sgsn->cfg.auth_policy = saved_auth_policy;
subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
@@ -986,9 +1007,11 @@ static void test_gmm_attach_subscr_real_auth(void)
subscr_put(subscr);
printf("Auth policy 'remote', triplet based auth: ");
+
test_gmm_attach(0);
cleanup_subscr_by_imsi("123456789012345");
+ assert_no_subscrs();
sgsn->cfg.auth_policy = saved_auth_policy;
subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
@@ -1074,9 +1097,8 @@ static void test_gmm_attach_subscr_gsup_auth(int retry)
printf("Auth policy 'remote', GSUP based auth: ");
test_gmm_attach(retry);
- subscr = gprs_subscr_get_by_imsi("123456789012345");
- OSMO_ASSERT(subscr != NULL);
- gprs_subscr_delete(subscr);
+ cleanup_subscr_by_imsi("123456789012345");
+ assert_no_subscrs();
sgsn->cfg.auth_policy = saved_auth_policy;
subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
@@ -1157,7 +1179,7 @@ static void test_gmm_attach_subscr_real_gsup_auth(int retry)
osmo_timers_update();
- OSMO_ASSERT(gprs_subscr_get_by_imsi("123456789012345") == NULL);
+ assert_no_subscrs();
sgsn->cfg.auth_policy = saved_auth_policy;
sgsn_inst.cfg.subscriber_expiry_timeout = SGSN_TIMEOUT_NEVER;