From: Peter Hutterer <peter.hutterer@who-t.net>
To: Enric Balletbo i Serra <eballetbo@kernel.org>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Shuah Khan <shuah@kernel.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Javier Martinez Canillas <javierm@redhat.com>,
Dana Elfassy <delfassy@redhat.com>,
linux-input@vger.kernel.org, phuttere@redhat.com,
Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: Re: [PATCH v2] selftests/input: Introduce basic tests for evdev ioctls
Date: Tue, 6 Jun 2023 15:04:31 +1000 [thread overview]
Message-ID: <20230606050431.GA3789903@quokka> (raw)
In-Reply-To: <20230530102627.87284-1-eballetbo@kernel.org>
On Tue, May 30, 2023 at 12:26:27PM +0200, Enric Balletbo i Serra wrote:
> This provides a basic infrastructure for the creation of tests for the evdev
> interface. Most of this code is adapted from the libevdev wrapper library. While
> most of evdev ioctls are covered and tested using libevdev tests there are some
> evdev ioctls that aren't because are not supported (and will not be supported)
> by libevdev [1]. So, adding, at least those tests, would make sense.
>
> The test creates an uinput device (and an evdev device) so you can
> call the wanted ioctl from userspace. So, to run those tests you need
> to have support for uinput and evdev as well.
>
> [1] For example, libevdev doesn't support setting EV_REP because it's inherently
> racy - one libevdev context to set those values via the ioctl would cause all
> other libevdev contexts on the same device to be out of sync. Since we do not
> get notifications when the values changed, libevdev's buffered values for EV_REP
> will remain whatever they were initially.
>
> Signed-off-by: Enric Balletbo i Serra <eballetbo@kernel.org>
thanks, this mostly LGTM but there's still a bug left in the vararg
handling.
[...]
> +#include <dirent.h>
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <linux/uinput.h>
> +#include <poll.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <sys/stat.h>
> +#include <time.h>
> +#include <unistd.h>
> +
> +#include "../kselftest_harness.h"
> +
> +#define TEST_DEVICE_NAME "selftest input device"
> +
> +struct selftest_uinput {
> + int uinput_fd; /** file descriptor to uinput */
> + int evdev_fd; /** file descriptor to evdev */
> + char *name; /** device name */
> + char *syspath; /** /sys path */
> + char *devnode; /** device node */
nitpick: none of name, syspath, devnode are used in the tests and it's
likely they'll never need to be so there's no reason to strdup them
here. You could change fetch_syspath_and_devnode() to open_devnode() and
return the opened fd, meaning you can reduce the code even more.
[...]
> +
> +TEST(eviocgname_get_device_name)
> +{
> + struct selftest_uinput *uidev;
> + char buf[256];
> + int rc;
> +
> + rc = selftest_uinput_create_device(&uidev);
this one and the others without extra arguments need to be:
rc = selftest_uinput_create_device(&uidev, -1);
otherwise the vararg loop is going to keep the room warm for no reason.
Cheers,
Peter
next prev parent reply other threads:[~2023-06-06 5:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 10:26 [PATCH v2] selftests/input: Introduce basic tests for evdev ioctls Enric Balletbo i Serra
2023-06-06 5:04 ` Peter Hutterer [this message]
2023-06-06 8:08 ` Muhammad Usama Anjum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230606050431.GA3789903@quokka \
--to=peter.hutterer@who-t.net \
--cc=benjamin.tissoires@redhat.com \
--cc=delfassy@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=eballetbo@kernel.org \
--cc=javierm@redhat.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=phuttere@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox