From de4bbc714600b9db0b913705efc3064defacae18 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 24 Nov 2014 15:04:15 +0100 Subject: [PATCH] sgsn/test: Add test case for unexpected Detach Accepts The commit "sgsn: Don't send XID reset after Detach Accept" fixed the SGSN to not respond to a Detach Accept message when there is no MM context. This patch adds a test case to verify, that there is really no message sent in that case. The test fails when the commit mentioned aboved is reverted. Sponsored-by: On-Waves ehf --- openbsc/tests/sgsn/sgsn_test.c | 35 +++++++++++++++++++++++++++++++++ openbsc/tests/sgsn/sgsn_test.ok | 1 + 2 files changed, 36 insertions(+) diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index 464f4d742..533c393c8 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -256,6 +256,40 @@ static void test_gmm_detach_no_mmctx(void) OSMO_ASSERT(count(gprs_llme_list()) == 0); } +/* + * Test that a single GMM Detach Accept message will not cause the SGSN to send + * any message or leave an MM context at the SGSN. + */ +static void test_gmm_detach_accept_unexpected(void) +{ + struct gprs_llc_lle *lle; + uint32_t local_tlli; + + printf("Testing GMM detach accept (unexpected)\n"); + + /* DTAP - Detach Accept (MT) */ + /* normal detach */ + static const unsigned char detach_acc[] = { + 0x08, 0x06 + }; + + /* Create an LLME */ + OSMO_ASSERT(count(gprs_llme_list()) == 0); + local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL); + lle = gprs_lle_get_or_create(local_tlli, 3); + + /* inject the detach */ + send_0408_message(lle->llme, local_tlli, + detach_acc, ARRAY_SIZE(detach_acc)); + + /* verify that no message (and therefore no Status or XID reset) has been + * sent by the SGSN */ + OSMO_ASSERT(sgsn_tx_counter == 0); + + /* verify that things are gone */ + OSMO_ASSERT(count(gprs_llme_list()) == 0); +} + /* * Test that a GMM Status will remove the associated LLME if there is no MMCTX. */ @@ -812,6 +846,7 @@ int main(int argc, char **argv) test_gmm_detach(); test_gmm_detach_power_off(); test_gmm_detach_no_mmctx(); + test_gmm_detach_accept_unexpected(); test_gmm_status_no_mmctx(); test_gmm_attach(); test_gmm_reject(); diff --git a/openbsc/tests/sgsn/sgsn_test.ok b/openbsc/tests/sgsn/sgsn_test.ok index 6f6204ff5..db9631193 100644 --- a/openbsc/tests/sgsn/sgsn_test.ok +++ b/openbsc/tests/sgsn/sgsn_test.ok @@ -2,6 +2,7 @@ Testing LLME allocations Testing GMM detach Testing GMM detach (power off) Testing GMM detach (no MMCTX) +Testing GMM detach accept (unexpected) Testing GMM Status (no MMCTX) Testing GMM attach Testing GMM reject