tests: new test case for gpioget
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 12 Jun 2017 19:01:10 +0000 (21:01 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 12 Jun 2017 19:01:10 +0000 (21:01 +0200)
Verify that gpioget correctly bails out if the user requested to read
more GPIO lines than the number exposed by the chip.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
tests/tests-gpioget.c

index dfbb84a22514f61b357d19544eb3d20a21492bd1..302e341499e3c41fe489d1e96ca4253c1d94561c 100644 (file)
@@ -82,3 +82,20 @@ static void gpioget_no_lines_specified(void)
 TEST_DEFINE(gpioget_no_lines_specified,
            "tools: gpioget - no lines specified",
            0, { 4, 4 });
+
+static void gpioget_too_many_lines_specified(void)
+{
+       test_tool_run("gpioget", "gpiochip1",
+                     "0", "1", "2", "3", "4", (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_NOT_NULL(test_tool_stderr());
+       TEST_ASSERT_STR_CONTAINS(test_tool_stderr(),
+                                "error reading GPIO values");
+}
+TEST_DEFINE(gpioget_too_many_lines_specified,
+           "tools: gpioget - too many lines specified",
+           0, { 4 });