[systemd-devel] [PATCH] test: check what happens if we forget about KDBUS_CMD_FREE call
Lukasz Skalski
l.skalski at samsung.com
Wed Feb 11 05:33:34 PST 2015
diff --git a/test/test-free.c b/test/test-free.c
index 01dca80..f666da3 100644
--- a/test/test-free.c
+++ b/test/test-free.c
@@ -14,6 +14,22 @@
#include "kdbus-enum.h"
#include "kdbus-test.h"
+static int sample_ioctl_call(struct kdbus_test_env *env)
+{
+ int ret;
+ struct kdbus_cmd_list cmd_list = {
+ .flags = KDBUS_LIST_QUEUED,
+ .size = sizeof(cmd_list),
+ };
+
+ ret = kdbus_cmd_list(env->conn->fd, &cmd_list);
+ ASSERT_RETURN(ret == 0);
+
+ /* DON'T FREE THIS SLICE OF MEMORY! */
+
+ return TEST_OK;
+}
+
int kdbus_test_free(struct kdbus_test_env *env)
{
int ret;
@@ -32,5 +48,17 @@ int kdbus_test_free(struct kdbus_test_env *env)
ret = kdbus_cmd_free(env->conn->fd, &cmd_free);
ASSERT_RETURN(ret == -ENXIO);
+ /*
+ * The user application is responsible for freeing the allocated
+ * memory with the KDBUS_CMD_FREE ioctl, so let's test what happens
+ * if we forget about it.
+ */
+
+ ret = sample_ioctl_call(env);
+ ASSERT_RETURN(ret == 0);
+
+ ret = sample_ioctl_call(env);
+ ASSERT_RETURN(ret == 0);
+
return TEST_OK;
}
--
1.9.3
More information about the systemd-devel
mailing list