tests: make the devpath check less strict
authorBartosz Golaszewski <bartekgola@gmail.com>
Tue, 14 Nov 2017 12:37:01 +0000 (13:37 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Tue, 14 Nov 2017 13:13:52 +0000 (14:13 +0100)
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 <bartekgola@gmail.com>
tests/gpiod-test.c

index 0c68e8ccd559baceb2da7d6ecb4c262a1105916e..918bbcb2fc0b6a9978ce9f1eb609bd1d8a1ce0ca 100644 (file)
@@ -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);
 }