From: Bartosz Golaszewski Date: Thu, 8 Jun 2017 13:19:01 +0000 (+0200) Subject: tests: add a test case for gpioinfo X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=694e789e11715f06617d46d4113d4d3cc306aee3;p=qemu-gpiodev%2Flibgpiod.git tests: add a test case for gpioinfo Add a simple test for gpioinfo. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/Makefile.am b/tests/Makefile.am index a07bce6..794b825 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,7 +24,8 @@ gpiod_test_SOURCES = gpiod-test.c \ if WITH_TOOLS -gpiod_test_SOURCES += tests-gpiodetect.c +gpiod_test_SOURCES += tests-gpiodetect.c \ + tests-gpioinfo.c endif diff --git a/tests/tests-gpioinfo.c b/tests/tests-gpioinfo.c new file mode 100644 index 0000000..0aca130 --- /dev/null +++ b/tests/tests-gpioinfo.c @@ -0,0 +1,30 @@ +/* + * Test cases for the gpioinfo tool. + * + * Copyright (C) 2017 Bartosz Golaszewski + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License + * as published by the Free Software Foundation. + */ + +#include "gpiod-test.h" + +static void gpioinfo_good(void) +{ + test_gpiotool_run("gpioinfo", (char *)NULL); + test_tool_wait(); + + TEST_ASSERT(test_tool_exited()); + TEST_ASSERT_RET_OK(test_tool_exit_status()); + TEST_ASSERT_NOT_NULL(test_tool_stdout()); + TEST_ASSERT_STR_CONTAINS(test_tool_stdout(), "gpiochip0 - 4 lines:"); + TEST_ASSERT_STR_CONTAINS(test_tool_stdout(), "gpiochip1 - 8 lines:"); + TEST_ASSERT_REGEX_MATCH(test_tool_stdout(), + "\\s+line\\s+0:\\s+unnamed\\s+unused\\s+output\\s+active-high"); + TEST_ASSERT_REGEX_MATCH(test_tool_stdout(), + "\\s+line\\s+7:\\s+unnamed\\s+unused\\s+output\\s+active-high"); +} +TEST_DEFINE(gpioinfo_good, + "tools: gpioinfo - good", + 0, { 4, 8 });