summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-06-07 15:42:22 +0200
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2011-06-07 15:42:57 +0200
commitf0b59990b2f557360b745c127e87d5461fdc3a32 (patch)
tree659b88fe0565355ae50bc4525bdb5c1d1a098084
parent89f4a464c6c2493feb1b8ab1f0801553009cd359 (diff)
downloadconnman-f0b59990b2f557360b745c127e87d5461fdc3a32.tar.gz
connman-f0b59990b2f557360b745c127e87d5461fdc3a32.tar.bz2
connman-f0b59990b2f557360b745c127e87d5461fdc3a32.zip
unit: Add create many session test
-rw-r--r--unit/test-session.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/unit/test-session.c b/unit/test-session.c
index 2c993f36..ef380162 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();
}