From: Bartosz Golaszewski Date: Tue, 14 Nov 2017 12:37:01 +0000 (+0100) Subject: tests: make the devpath check less strict X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3a3d69137b4c2fdcbcfe89ed55ea0c15dd0d7573;p=qemu-gpiodev%2Flibgpiod.git tests: make the devpath check less strict We plan to change the way gpio-mockup platform devices are registered in the kernel. This change will add an ID to the gpio-mockup platform device name and will result in the devpath being changed to '/devices/platform/gpio-mockup.X/gpiochip'. When checking the devpath during the test case setup, it's enough to verify that we got an event from the correct platform device - we don't need to check the gpiochip name. Shorten the string against which we check to skip whatever comes after the platform device name. While we're at it: move the string definition into the function which is the only user. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index 0c68e8c..918bbcb 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -33,8 +33,6 @@ #define NORETURN __attribute__((noreturn)) #define MALLOC __attribute__((malloc)) -static const char mockup_devpath[] = "/devices/platform/gpio-mockup/gpiochip"; - static const unsigned int min_kern_major = 4; static const unsigned int min_kern_minor = 12; static const unsigned int min_kern_release = 6; @@ -807,6 +805,8 @@ static int chipcmp(const void *c1, const void *c2) static bool devpath_is_mockup(const char *devpath) { + static const char mockup_devpath[] = "/devices/platform/gpio-mockup"; + return !strncmp(devpath, mockup_devpath, sizeof(mockup_devpath) - 1); }