sgsn/test: Move MM context allocation into separate function
This refactores serveral code lines needed for the allocation of MM contexts into the new function alloc_mm_ctx. Sponsored-by: On-Waves ehf
This commit is contained in:
parent
3b5d407203
commit
abc16a55b2
|
@ -66,6 +66,28 @@ static struct msgb *create_msg(const uint8_t *data, size_t len)
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a context and search for it
|
||||||
|
*/
|
||||||
|
static struct sgsn_mm_ctx *alloc_mm_ctx(uint32_t tlli, struct gprs_ra_id *raid)
|
||||||
|
{
|
||||||
|
struct sgsn_mm_ctx *ctx, *ictx;
|
||||||
|
struct gprs_llc_lle *lle;
|
||||||
|
int old_count = count(gprs_llme_list());
|
||||||
|
|
||||||
|
lle = gprs_lle_get_or_create(tlli, 3);
|
||||||
|
ctx = sgsn_mm_ctx_alloc(tlli, raid);
|
||||||
|
ctx->mm_state = GMM_REGISTERED_NORMAL;
|
||||||
|
ctx->llme = lle->llme;
|
||||||
|
|
||||||
|
ictx = sgsn_mm_ctx_by_tlli(tlli, raid);
|
||||||
|
OSMO_ASSERT(ictx == ctx);
|
||||||
|
|
||||||
|
OSMO_ASSERT(count(gprs_llme_list()) == old_count + 1);
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_llme(void)
|
static void test_llme(void)
|
||||||
{
|
{
|
||||||
struct gprs_llc_lle *lle, *lle_copy;
|
struct gprs_llc_lle *lle, *lle_copy;
|
||||||
|
@ -107,7 +129,6 @@ static void test_gmm_detach(void)
|
||||||
{
|
{
|
||||||
struct gprs_ra_id raid = { 0, };
|
struct gprs_ra_id raid = { 0, };
|
||||||
struct sgsn_mm_ctx *ctx, *ictx;
|
struct sgsn_mm_ctx *ctx, *ictx;
|
||||||
struct gprs_llc_lle *lle;
|
|
||||||
uint32_t local_tlli;
|
uint32_t local_tlli;
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
|
|
||||||
|
@ -120,17 +141,11 @@ static void test_gmm_detach(void)
|
||||||
0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
|
0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Create a conext and search for it */
|
|
||||||
OSMO_ASSERT(count(gprs_llme_list()) == 0);
|
|
||||||
local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL);
|
local_tlli = gprs_tmsi2tlli(0x23, TLLI_LOCAL);
|
||||||
lle = gprs_lle_get_or_create(local_tlli, 3);
|
|
||||||
ctx = sgsn_mm_ctx_alloc(local_tlli, &raid);
|
|
||||||
ctx->mm_state = GMM_REGISTERED_NORMAL;
|
|
||||||
ctx->llme = lle->llme;
|
|
||||||
|
|
||||||
ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);
|
/* Create a context */
|
||||||
OSMO_ASSERT(ictx == ctx);
|
OSMO_ASSERT(count(gprs_llme_list()) == 0);
|
||||||
OSMO_ASSERT(count(gprs_llme_list()) == 1);
|
ctx = alloc_mm_ctx(local_tlli, &raid);
|
||||||
|
|
||||||
/* inject the detach */
|
/* inject the detach */
|
||||||
msg = create_msg(detach_req, ARRAY_SIZE(detach_req));
|
msg = create_msg(detach_req, ARRAY_SIZE(detach_req));
|
||||||
|
|
Loading…
Reference in New Issue