From b19592f7134baeae1541e55b6efead887739291d Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 5 Jul 2012 23:28:50 +0200 Subject: paging: Update the unit test that would have caused the previous The unit test created and used the paging request in the same second and was passing because of that. Add a second test with a delay to force now to not be equal to the expiration time. --- tests/paging/paging_test.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/paging') diff --git a/tests/paging/paging_test.c b/tests/paging/paging_test.c index 6ce8220d..1aa56046 100644 --- a/tests/paging/paging_test.c +++ b/tests/paging/paging_test.c @@ -25,6 +25,8 @@ #include #include +#include + static struct gsm_bts *bts; static struct gsm_bts_role_bts *btsb; @@ -68,6 +70,33 @@ static void test_paging_smoke(void) */ } +static void test_paging_sleep(void) +{ + int rc; + uint8_t out_buf[GSM_MACBLOCK_LEN]; + struct gsm_time g_time; + printf("Testing that paging messages expire with sleep.\n"); + + /* add paging entry */ + rc = paging_add_identity(btsb->paging_state, 0, static_ilv, 0); + ASSERT_TRUE(rc == 0); + ASSERT_TRUE(paging_queue_length(btsb->paging_state) == 1); + + /* sleep */ + sleep(1); + + /* generate messages */ + g_time.fn = 0; + g_time.t1 = 0; + g_time.t2 = 0; + g_time.t3 = 6; + rc = paging_gen_msg(btsb->paging_state, out_buf, &g_time); + ASSERT_TRUE(rc == 13); + + ASSERT_TRUE(paging_group_queue_empty(btsb->paging_state, 0)); + ASSERT_TRUE(paging_queue_length(btsb->paging_state) == 0); +} + int main(int argc, char **argv) { void *tall_msgb_ctx; @@ -86,6 +115,7 @@ int main(int argc, char **argv) btsb = bts_role_bts(bts); test_paging_smoke(); + test_paging_sleep(); printf("Success\n"); return 0; -- cgit v1.2.3