summaryrefslogtreecommitdiff
path: root/unit/test-mgmt.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-12-05 15:38:10 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-12-12 12:24:11 -0200
commit2fb97fd691f166221fda3232d634d108daffb0d0 (patch)
treeabc45d6f8563fd5c20d98ba6e0f594c25a4e456a /unit/test-mgmt.c
parent329c7184d8818079ca6230e91f3228212cbde0c1 (diff)
downloadbluez-2fb97fd691f166221fda3232d634d108daffb0d0.tar.gz
unit/test-mgmt: Add /mgmt/unregister/1 test
This tests if mgmt_unregister_all can be called within event callback.
Diffstat (limited to 'unit/test-mgmt.c')
-rw-r--r--unit/test-mgmt.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/unit/test-mgmt.c b/unit/test-mgmt.c
index 331ee42ef..8dcaa4b5d 100644
--- a/unit/test-mgmt.c
+++ b/unit/test-mgmt.c
@@ -350,6 +350,32 @@ static void test_event2(gconstpointer data)
execute_context(context);
}
+static void unregister_all_cb(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct context *context = user_data;
+
+ mgmt_unregister_all(context->mgmt_client);
+
+ context_quit(context);
+}
+
+static void test_unregister_all(gconstpointer data)
+{
+ const struct command_test_data *test = data;
+ struct context *context = create_context();
+
+ mgmt_register(context->mgmt_client, test->opcode, test->index,
+ unregister_all_cb, context, NULL);
+ mgmt_register(context->mgmt_client, test->opcode, test->index,
+ event_cb, context, NULL);
+
+ g_assert_cmpint(write(context->fd, test->cmd_data, test->cmd_size), ==,
+ test->cmd_size);
+
+ execute_context(context);
+}
+
int main(int argc, char *argv[])
{
g_test_init(&argc, &argv, NULL);
@@ -365,5 +391,8 @@ int main(int argc, char *argv[])
g_test_add_data_func("/mgmt/event/1", &event_test_1, test_event);
g_test_add_data_func("/mgmt/event/2", &event_test_1, test_event2);
+ g_test_add_data_func("/mgmt/unregister/1", &event_test_1,
+ test_unregister_all);
+
return g_test_run();
}