diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-02-22 01:12:47 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-02-22 01:12:47 -0300 |
commit | 6d461a4fe7896faa1aec5a5417888cf179e46b9f (patch) | |
tree | 2e0f1a0b7a5418189c8d53592d33a44d0b356fc9 /tools/testing/selftests/kdbus/test-chat.c | |
parent | 5c545e1fb127a4b11ddc5f1a5ed066b853dd1a1a (diff) |
Linux-libre 4.4.2-gnupck-4.4.2-gnu
Diffstat (limited to 'tools/testing/selftests/kdbus/test-chat.c')
-rw-r--r-- | tools/testing/selftests/kdbus/test-chat.c | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/tools/testing/selftests/kdbus/test-chat.c b/tools/testing/selftests/kdbus/test-chat.c deleted file mode 100644 index 41e5b53fe..000000000 --- a/tools/testing/selftests/kdbus/test-chat.c +++ /dev/null @@ -1,124 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <time.h> -#include <fcntl.h> -#include <stdlib.h> -#include <stddef.h> -#include <unistd.h> -#include <stdint.h> -#include <errno.h> -#include <assert.h> -#include <poll.h> -#include <stdbool.h> - -#include "kdbus-test.h" -#include "kdbus-util.h" -#include "kdbus-enum.h" - -int kdbus_test_chat(struct kdbus_test_env *env) -{ - int ret, cookie; - struct kdbus_conn *conn_a, *conn_b; - struct pollfd fds[2]; - uint64_t flags; - int count; - - conn_a = kdbus_hello(env->buspath, 0, NULL, 0); - conn_b = kdbus_hello(env->buspath, 0, NULL, 0); - ASSERT_RETURN(conn_a && conn_b); - - flags = KDBUS_NAME_ALLOW_REPLACEMENT; - ret = kdbus_name_acquire(conn_a, "foo.bar.test", &flags); - ASSERT_RETURN(ret == 0); - - ret = kdbus_name_acquire(conn_a, "foo.bar.baz", NULL); - ASSERT_RETURN(ret == 0); - - flags = KDBUS_NAME_QUEUE; - ret = kdbus_name_acquire(conn_b, "foo.bar.baz", &flags); - ASSERT_RETURN(ret == 0); - - ret = kdbus_name_acquire(conn_a, "foo.bar.double", NULL); - ASSERT_RETURN(ret == 0); - - flags = 0; - ret = kdbus_name_acquire(conn_a, "foo.bar.double", &flags); - ASSERT_RETURN(ret == 0); - ASSERT_RETURN(!(flags & KDBUS_NAME_ACQUIRED)); - - ret = kdbus_name_release(conn_a, "foo.bar.double"); - ASSERT_RETURN(ret == 0); - - ret = kdbus_name_release(conn_a, "foo.bar.double"); - ASSERT_RETURN(ret == -ESRCH); - - ret = kdbus_list(conn_b, KDBUS_LIST_UNIQUE | - KDBUS_LIST_NAMES | - KDBUS_LIST_QUEUED | - KDBUS_LIST_ACTIVATORS); - ASSERT_RETURN(ret == 0); - - ret = kdbus_add_match_empty(conn_a); - ASSERT_RETURN(ret == 0); - - ret = kdbus_add_match_empty(conn_b); - ASSERT_RETURN(ret == 0); - - cookie = 0; - ret = kdbus_msg_send(conn_b, NULL, 0xc0000000 | cookie, 0, 0, 0, - KDBUS_DST_ID_BROADCAST); - ASSERT_RETURN(ret == 0); - - fds[0].fd = conn_a->fd; - fds[1].fd = conn_b->fd; - - kdbus_printf("-- entering poll loop ...\n"); - - for (count = 0;; count++) { - int i, nfds = sizeof(fds) / sizeof(fds[0]); - - for (i = 0; i < nfds; i++) { - fds[i].events = POLLIN | POLLPRI | POLLHUP; - fds[i].revents = 0; - } - - ret = poll(fds, nfds, 3000); - ASSERT_RETURN(ret >= 0); - - if (fds[0].revents & POLLIN) { - if (count > 2) - kdbus_name_release(conn_a, "foo.bar.baz"); - - ret = kdbus_msg_recv(conn_a, NULL, NULL); - ASSERT_RETURN(ret == 0); - ret = kdbus_msg_send(conn_a, NULL, - 0xc0000000 | cookie++, - 0, 0, 0, conn_b->id); - ASSERT_RETURN(ret == 0); - } - - if (fds[1].revents & POLLIN) { - ret = kdbus_msg_recv(conn_b, NULL, NULL); - ASSERT_RETURN(ret == 0); - ret = kdbus_msg_send(conn_b, NULL, - 0xc0000000 | cookie++, - 0, 0, 0, conn_a->id); - ASSERT_RETURN(ret == 0); - } - - ret = kdbus_list(conn_b, KDBUS_LIST_UNIQUE | - KDBUS_LIST_NAMES | - KDBUS_LIST_QUEUED | - KDBUS_LIST_ACTIVATORS); - ASSERT_RETURN(ret == 0); - - if (count > 10) - break; - } - - kdbus_printf("-- closing bus connections\n"); - kdbus_conn_free(conn_a); - kdbus_conn_free(conn_b); - - return TEST_OK; -} |