From 152eac220c3cd184b1d99f624b83db28df4b4cb1 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Wed, 15 Mar 2017 14:40:59 +0100 Subject: [PATCH] tests: require at least linux v4.11 This is the first linux kernel release that supports GPIO event injecting over debugfs. Make it a hard requirement for running tests. Signed-off-by: Bartosz Golaszewski --- tests/unit/gpiod-unit.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/unit/gpiod-unit.c b/tests/unit/gpiod-unit.c index ffd4231..edb30b9 100644 --- a/tests/unit/gpiod-unit.c +++ b/tests/unit/gpiod-unit.c @@ -18,6 +18,7 @@ #include #include #include +#include #define NORETURN __attribute__((noreturn)) #define MALLOC __attribute__((malloc)) @@ -228,6 +229,28 @@ static void module_cleanup(void) kmod_unref(globals.module_ctx); } +static void check_kernel(void) +{ + int status, version, patchlevel; + struct utsname un; + + msg("checking the linux kernel version"); + + status = uname(&un); + if (status) + die_perr("uname"); + + status = sscanf(un.release, "%d.%d", &version, &patchlevel); + if (status != 2) + die("error reading kernel release version"); + + if (version < 4 || patchlevel < 11) + die("linux kernel version must be at least v4.11 - got v%d.%d", + version, patchlevel); + + msg("kernel release is v%d.%d - ok to run tests", version, patchlevel); +} + static void check_gpio_mockup(void) { const char *modpath; @@ -421,6 +444,7 @@ int main(int argc GU_UNUSED, char **argv GU_UNUSED) msg("libgpiod unit-test suite"); msg("%u tests registered", globals.num_tests); + check_kernel(); check_gpio_mockup(); msg("running tests"); -- 2.30.2