tests: new test case for gpiodetect
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 12 Jun 2017 10:51:30 +0000 (12:51 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 12 Jun 2017 10:51:30 +0000 (12:51 +0200)
Verify that we bail out if the user passes any non-option argument
to gpiodetect.

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

index b39d551d2d7b7a5c831c5bac34d012a5a2d075c5..8385beb002a4b42df0f2762b48d754c1fd254f41 100644 (file)
@@ -44,3 +44,18 @@ static void gpiodetect_simple(void)
 TEST_DEFINE(gpiodetect_simple,
            "tools: gpiodetect - simple",
            0, { 4, 8, 16 });
+
+static void gpiodetect_invalid_args(void)
+{
+       test_gpiotool_run("gpiodetect", "unused argument", (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(), "unrecognized argument");
+}
+TEST_DEFINE(gpiodetect_invalid_args,
+           "tools: gpiodetect - invalid arguments",
+           0, { });