aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-07-05 23:28:50 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-07-05 23:31:18 +0200
commitb19592f7134baeae1541e55b6efead887739291d (patch)
tree2c73beb73ca1103265149786781f2503a01c8b9d /tests
parentcb7697074eb6b11b0a3d39794b85691491cfd131 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/paging/paging_test.c30
1 files changed, 30 insertions, 0 deletions
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 <osmo-bts/paging.h>
#include <osmo-bts/gsm_data.h>
+#include <unistd.h>
+
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;