[PATCH libevdev 9/9] test: test for logging function

Benjamin Tissoires benjamin.tissoires at gmail.com
Mon Sep 9 08:09:40 PDT 2013


On Tue, Sep 3, 2013 at 9:07 AM, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  test/test-libevdev-init.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/test/test-libevdev-init.c b/test/test-libevdev-init.c
> index 8f1d0d1..2610975 100644
> --- a/test/test-libevdev-init.c
> +++ b/test/test-libevdev-init.c
> @@ -93,10 +93,16 @@ START_TEST(test_init_and_change_fd)
>  }
>  END_TEST
>
> +
> +static int log_fn_called = 0;
> +static char *logdata = "test";
>  static void logfunc(enum libevdev_log_priority priority,
>                     void *data,
>                     const char *file, int line, const char *func,
> -                   const char *f, va_list args) {}
> +                   const char *f, va_list args) {
> +       ck_assert_int_eq(strcmp(logdata, data), 0);
> +       log_fn_called++;
> +}
>
>  START_TEST(test_log_init)
>  {
> @@ -107,16 +113,19 @@ START_TEST(test_log_init)
>
>         dev = libevdev_new();
>         ck_assert(dev != NULL);
> -       libevdev_set_log_function(logfunc, NULL);
> -       libevdev_free(dev);
>
> -       dev = libevdev_new();
> -       ck_assert(dev != NULL);
> +       libevdev_set_log_function(logfunc, logdata);
> +       libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
> +
>         libevdev_set_log_function(NULL, NULL);
> -       libevdev_set_log_function(logfunc, NULL);
> +       libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
> +
> +       libevdev_set_log_function(logfunc, logdata);

Shoudn't this be "libevdev_set_log_function(logfunc, NULL);"?
Otherwise, I don't get the "2" below.

Cheers,
Benjamin

> +       libevdev_next_event(dev, LIBEVDEV_READ_NORMAL, NULL);
> +
> +       ck_assert_int_eq(log_fn_called, 2);
> +
>         libevdev_free(dev);
> -       /* well, we didn't crash. can't test this otherwise */
> -
>  }
>  END_TEST
>
> --
> 1.8.2.1
>
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/input-tools


More information about the Input-tools mailing list