From: Daniel Wagner Date: Tue, 7 Jun 2011 13:42:22 +0000 (+0200) Subject: unit: Add create many session test X-Git-Tag: 2.0_alpha~1418 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0b59990b2f557360b745c127e87d5461fdc3a32;p=framework%2Fconnectivity%2Fconnman.git unit: Add create many session test --- diff --git a/unit/test-session.c b/unit/test-session.c index 2c993f3..ef38016 100644 --- a/unit/test-session.c +++ b/unit/test-session.c @@ -166,6 +166,48 @@ static gboolean test_session_create_already_exists(gpointer data) return FALSE; } +static void test_session_create_many_notify(struct test_session *session) +{ + unsigned int nr; + + LOG("session %p", session); + + g_assert(is_connman_running(session->connection) == TRUE); + + nr = GPOINTER_TO_UINT(session->fix->user_data); + nr--; + session->fix->user_data = GUINT_TO_POINTER(nr); + + if (nr > 0) + return; + + util_idle_call(session->fix, util_quit_loop, util_session_destroy); +} + +static gboolean test_session_create_many(gpointer data) +{ + struct test_fix *fix = data; + struct test_session *session; + unsigned int i, max; + + max = 100; + + fix->user_data = GUINT_TO_POINTER(max); + + util_session_create(fix, max); + + for (i = 0; i < max; i++) { + session = &fix->session[i]; + + session->notify_path = g_strdup_printf("/foo/%d", i); + session->notify = test_session_create_many_notify; + + util_session_init(session); + } + + return FALSE; +} + static void set_session_mode(struct test_fix *fix, connman_bool_t enable) { @@ -228,6 +270,8 @@ int main(int argc, char *argv[]) test_session_create_destroy, setup_cb, teardown_cb); util_test_add("/manager/session create already exists", test_session_create_already_exists, setup_cb, teardown_cb); + util_test_add("/manager/session create many", + test_session_create_many, setup_cb, teardown_cb); return g_test_run(); }