From 08e324fda7d742400b1a5d83363139b71365fd77 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 6 Jan 2012 14:06:56 +0100 Subject: channel: Make the test not crash again. * Initialize logging * The callback expects NULL or a subscriber connection --- openbsc/tests/channel/channel_test.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'openbsc/tests/channel') diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c index 1121dd5ad..440e1803c 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -22,9 +22,15 @@ #include +#include #include -#include + #include +#include +#include + +static int s_end = 0; +static struct gsm_subscriber_connection s_conn; /* our handler */ static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, void *data, void *param) @@ -32,16 +38,17 @@ static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, vo assert(hook == 101); assert(event == 200); assert(msg == (void*)0x1323L); - assert(data == (void*)0x4242L); + assert(data == &s_conn); assert(param == (void*)0x2342L); printf("Reached, didn't crash, test passed\n"); + s_end = true; return 0; } /* mock object for testing, directly invoke the cb... maybe later through the timer */ void paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data) { - cbfn(101, 200, (void*)0x1323L, (void*)0x4242L, data); + cbfn(101, 200, (void*)0x1323L, &s_conn, data); } @@ -50,6 +57,8 @@ int main(int argc, char **argv) struct gsm_network *network; struct gsm_bts *bts; + osmo_init_logging(&log_info); + printf("Testing the gsm_subscriber chan logic\n"); /* Create a dummy network */ @@ -67,9 +76,11 @@ int main(int argc, char **argv) /* Ask for a channel... */ subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L); - while (1) { + while (!s_end) { osmo_select_main(0); } + + return EXIT_SUCCESS; } void _abis_nm_sendmsg() {} -- cgit v1.2.3