tests: add a test case for gpioinfo
authorBartosz Golaszewski <bartekgola@gmail.com>
Thu, 8 Jun 2017 13:19:01 +0000 (15:19 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 8 Jun 2017 13:19:01 +0000 (15:19 +0200)
Add a simple test for gpioinfo.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
tests/Makefile.am
tests/tests-gpioinfo.c [new file with mode: 0644]

index a07bce643768d40ced71b36e3506283837832ff6..794b82556321557d59a2e5748c7cec70be7ab904 100644 (file)
@@ -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 (file)
index 0000000..0aca130
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Test cases for the gpioinfo tool.
+ *
+ * Copyright (C) 2017 Bartosz Golaszewski <bartekgola@gmail.com>
+ *
+ * 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 });