MSC: add a test case to check T3212 expiration during paging

Long story short: some time ago I noticed that OsmoMSC crashes if
T3212 expires during the Paging procedure. This is not the case
anymore (as the test case shows) and apparently the bug has been
fixed, hovewer I believe it makes sense to add this test case.

Change-Id: If9147ae8b07d5120d2853b9acda2313910ac48be
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index ccfc154..cf91b1e 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -5896,6 +5896,44 @@
 	vc_conn.done;
 }
 
+/* Verify the case when T3212 expires during Paging procedure, just before the receipt
+ * of Paging Response. This used to provoke a NULL-pointer dereference in old versions
+ * of OsmoMSC, but apparently the bug has been fixed, and we're safe now. */
+friend function f_tc_lu_and_expire_while_paging(charstring id, BSC_ConnHdlrPars pars)
+runs on BSC_ConnHdlr {
+	var charstring imsi := hex2str(pars.imsi);
+
+	f_init_handler(pars);
+
+	/* Perform location update */
+	f_perform_lu();
+
+	f_ran_register_imsi(g_pars.imsi, g_pars.tmsi);
+	f_create_gsup_expect(hex2str(g_pars.imsi));
+
+	/* Initiate paging procedure from the VTY */
+	f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " paging");
+	f_expect_paging();
+
+	/* Emulate T3212 expiration during paging (we don't want to wait, right?) */
+	f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " expire");
+
+	/* MS sends PAGING RESPONSE, *old* OsmoMSC crashes here... */
+	f_establish_fully(EST_TYPE_PAG_RESP);
+
+	/* The recent OsmoMSC keeps subscriber in its VLR unless the Paging is completed.
+	 * In this case we do not send anything and just wait for a Clear Command. */
+	f_expect_clear();
+}
+testcase TC_lu_and_expire_while_paging() runs on MTC_CT {
+	var BSC_ConnHdlr vc_conn;
+
+	f_init();
+
+	vc_conn := f_start_handler(refers(f_tc_lu_and_expire_while_paging), 7);
+	vc_conn.done;
+}
+
 control {
 	execute( TC_cr_before_reset() );
 	execute( TC_lu_imsi_noauth_tmsi() );
@@ -6034,6 +6072,7 @@
 	}
 	execute( TC_invalid_mgcp_crash() );
 	execute( TC_mm_id_resp_no_identity() );
+	execute( TC_lu_and_expire_while_paging() );
 }