6 /* Use in conjunction with test-kdbus-daemon */
14 #include <sys/ioctl.h>
16 #include "kdbus-test.h"
17 #include "kdbus-util.h"
18 #include "kdbus-enum.h"
20 int get_file(const char *fname, int flags, const char *content)
24 if (access(fname, F_OK) < 0) {
25 f = fopen(fname, "w");
28 fprintf(f, "%s\n", content);
32 return open(fname, flags);
35 int kdbus_test_send(struct kdbus_test_env *env)
45 fds[0] = get_file("/tmp/kdbus-test-send.rd", O_RDONLY, "foo");
46 fds[1] = get_file("/tmp/kdbus-test-send.wr", O_WRONLY, "bar");
47 fds[2] = get_file("/tmp/kdbus-test-send.rdwr", O_RDWR, "baz");
49 for (i = 0; i < ELEMENTSOF(fds); i++) {
51 fprintf(stderr, "Unable to open data/fileN file(s)\n");
56 ret = kdbus_msg_send(env->conn, "com.example.kdbus-test", serial++,
59 fprintf(stderr, "error sending simple message: %d (%m)\n",
62 ret = kdbus_msg_send(env->conn, "com.example.kdbus-test", serial++,
65 fprintf(stderr, "error sending message with 1 fd: %d (%m)\n",
68 ret = kdbus_msg_send(env->conn, "com.example.kdbus-test", serial++,
71 fprintf(stderr, "error sending message with 2 fds: %d (%m)\n",
74 ret = kdbus_msg_send(env->conn, "com.example.kdbus-test", serial++,
77 fprintf(stderr, "error sending message with 3 fds: %d (%m)\n",
80 for (i = 0; i < ELEMENTSOF(fds); i++)