12 #include "kdbus-api.h"
13 #include "kdbus-util.h"
14 #include "kdbus-enum.h"
15 #include "kdbus-test.h"
17 static int sample_ioctl_call(struct kdbus_test_env *env)
20 struct kdbus_cmd_list cmd_list = {
21 .flags = KDBUS_LIST_QUEUED,
22 .size = sizeof(cmd_list),
25 ret = kdbus_cmd_list(env->conn->fd, &cmd_list);
26 ASSERT_RETURN(ret == 0);
28 /* DON'T FREE THIS SLICE OF MEMORY! */
33 int kdbus_test_free(struct kdbus_test_env *env)
36 struct kdbus_cmd_free cmd_free = {};
38 /* free an unallocated buffer */
39 cmd_free.size = sizeof(cmd_free);
42 ret = kdbus_cmd_free(env->conn->fd, &cmd_free);
43 ASSERT_RETURN(ret == -ENXIO);
45 /* free a buffer out of the pool's bounds */
46 cmd_free.size = sizeof(cmd_free);
47 cmd_free.offset = POOL_SIZE + 1;
48 ret = kdbus_cmd_free(env->conn->fd, &cmd_free);
49 ASSERT_RETURN(ret == -ENXIO);
52 * The user application is responsible for freeing the allocated
53 * memory with the KDBUS_CMD_FREE ioctl, so let's test what happens
54 * if we forget about it.
57 ret = sample_ioctl_call(env);
58 ASSERT_RETURN(ret == 0);
60 ret = sample_ioctl_call(env);
61 ASSERT_RETURN(ret == 0);