summaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-01-08 14:08:16 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-18 18:26:03 +0100
commitd3cde1ecf49940fae90ec5e1d36824ee0ba17501 (patch)
treef7ce3a171a445404e47bcb6adb4208c3b9611682 /openbsc/tests
parentf06fe29f61c0089ca2f0c10faea18c65d5014f95 (diff)
gprs/test: Move subscr cleanup code into a separate function
Refactor several occurences of the same subscriber cleanup code into a seperate cleanup_subscr_by_imsi function. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 6980a9015..ba76f5575 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -836,6 +836,15 @@ int my_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) {
return 0;
};
+static void cleanup_subscr_by_imsi(const char *imsi)
+{
+ struct gsm_subscriber *subscr;
+
+ subscr = gprs_subscr_get_by_imsi(imsi);
+ OSMO_ASSERT(subscr != NULL);
+ gprs_subscr_delete(subscr);
+}
+
static void test_gmm_attach_subscr(void)
{
const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;
@@ -852,9 +861,7 @@ static void test_gmm_attach_subscr(void)
printf("Auth policy 'remote': ");
test_gmm_attach(0);
- subscr = gprs_subscr_get_by_imsi("123456789012345");
- OSMO_ASSERT(subscr != NULL);
- gprs_subscr_delete(subscr);
+ cleanup_subscr_by_imsi("123456789012345");
sgsn->cfg.auth_policy = saved_auth_policy;
subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
@@ -889,9 +896,7 @@ static void test_gmm_attach_subscr_fake_auth(void)
printf("Auth policy 'remote', auth faked: ");
test_gmm_attach(0);
- subscr = gprs_subscr_get_by_imsi("123456789012345");
- OSMO_ASSERT(subscr != NULL);
- gprs_subscr_delete(subscr);
+ cleanup_subscr_by_imsi("123456789012345");
sgsn->cfg.auth_policy = saved_auth_policy;
subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;
@@ -932,9 +937,7 @@ static void test_gmm_attach_subscr_real_auth(void)
printf("Auth policy 'remote', triplet based auth: ");
test_gmm_attach(0);
- subscr = gprs_subscr_get_by_imsi("123456789012345");
- OSMO_ASSERT(subscr != NULL);
- gprs_subscr_delete(subscr);
+ cleanup_subscr_by_imsi("123456789012345");
sgsn->cfg.auth_policy = saved_auth_policy;
subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;