From: Bartosz Golaszewski Date: Fri, 9 Jun 2017 07:42:04 +0000 (+0200) Subject: tests: add test cases for gpiofind X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5c70c6e184287dcbd3cd017ef07f5bded20f853d;p=qemu-gpiodev%2Flibgpiod.git tests: add test cases for gpiofind Verify the correct behavior of gpiofind in two cases: when it can find a GPIO line by name and when the requested line doesn't exist. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 794b825..26210e6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,6 +25,7 @@ gpiod_test_SOURCES = gpiod-test.c \ if WITH_TOOLS gpiod_test_SOURCES += tests-gpiodetect.c \ + tests-gpiofind.c \ tests-gpioinfo.c endif diff --git a/tests/tests-gpiofind.c b/tests/tests-gpiofind.c new file mode 100644 index 0000000..f2531c3 --- /dev/null +++ b/tests/tests-gpiofind.c @@ -0,0 +1,40 @@ +/* + * Test cases for the gpiofind 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 gpiofind_good(void) +{ + test_gpiotool_run("gpiofind", "gpio-mockup-B-7", (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_EQ(test_tool_stdout(), "gpiochip1 7\n"); + TEST_ASSERT_NULL(test_tool_stderr()); +} +TEST_DEFINE(gpiofind_good, + "tools: gpiofind - good", + TEST_FLAG_NAMED_LINES, { 4, 8 }); + +static void gpiofind_not_found(void) +{ + test_gpiotool_run("gpiofind", "nonexistent", (char *)NULL); + test_tool_wait(); + + TEST_ASSERT(test_tool_exited()); + TEST_ASSERT_EQ(test_tool_exit_status(), 1); + TEST_ASSERT_NULL(test_tool_stdout()); + TEST_ASSERT_NULL(test_tool_stderr()); +} +TEST_DEFINE(gpiofind_not_found, + "tools: gpiofind - not found", + TEST_FLAG_NAMED_LINES, { 4, 8 });