diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-12-08 13:31:44 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-12-12 12:24:11 -0200 |
commit | 110edd66611eb243bcb61e6fbb0f361b21d8c65b (patch) | |
tree | a1d226c42a9f97e10f07261d482937fd10b27bc0 /unit/test-mgmt.c | |
parent | c423d3e88c83c2a2c6bcd0d0b2025248773aece0 (diff) | |
download | bluez-110edd66611eb243bcb61e6fbb0f361b21d8c65b.tar.gz |
unit/test-mgmt: Add /mgmt/destroy/1 test
This tests if mgmt_unref can be called within event callback.
Diffstat (limited to 'unit/test-mgmt.c')
-rw-r--r-- | unit/test-mgmt.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/unit/test-mgmt.c b/unit/test-mgmt.c index 8cd55653c..c67678b9a 100644 --- a/unit/test-mgmt.c +++ b/unit/test-mgmt.c @@ -386,6 +386,17 @@ static void unregister_index_cb(uint16_t index, uint16_t length, context_quit(context); } +static void destroy_cb(uint16_t index, uint16_t length, const void *param, + void *user_data) +{ + struct context *context = user_data; + + mgmt_unref(context->mgmt_client); + context->mgmt_client = NULL; + + context_quit(context); +} + static void test_unregister_index(gconstpointer data) { const struct command_test_data *test = data; @@ -402,6 +413,22 @@ static void test_unregister_index(gconstpointer data) execute_context(context); } +static void test_destroy(gconstpointer data) +{ + const struct command_test_data *test = data; + struct context *context = create_context(); + + mgmt_register(context->mgmt_client, test->opcode, test->index, + destroy_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); @@ -422,5 +449,7 @@ int main(int argc, char *argv[]) g_test_add_data_func("/mgmt/unregister/2", &event_test_1, test_unregister_index); + g_test_add_data_func("/mgmt/destroy/1", &event_test_1, test_destroy); + return g_test_run(); } |