[systemd-devel] [PATCH] test: check what happens if we forget about KDBUS_CMD_FREE call
David Herrmann
dh.herrmann at gmail.com
Wed Feb 11 07:00:04 PST 2015
Hi
On Wed, Feb 11, 2015 at 2:33 PM, Lukasz Skalski <l.skalski at samsung.com> wrote:
> 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;
> }
Looks good, applied!
The resulting bug is also fixed in:
commit ea1ffca52af8f0c0d373b6eb78b019d07b369a4a
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Wed Feb 11 15:53:04 2015 +0100
pool: fix handling of empty slices
Thanks
David
More information about the systemd-devel
mailing list