tests: gpiomon: new test cases
authorBartosz Golaszewski <bartekgola@gmail.com>
Wed, 14 Jun 2017 08:37:56 +0000 (10:37 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Wed, 14 Jun 2017 08:37:56 +0000 (10:37 +0200)
Add test cases verifying the --silent mode and receiving
multiple events.

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

index ad5f846f90d04121a2086e778edf4792d7939e1a..890c1a6ab10c5e94948c73dde5698c80ff16863f 100644 (file)
@@ -27,3 +27,39 @@ static void gpiomon_single_rising_edge_event(void)
 TEST_DEFINE(gpiomon_single_rising_edge_event,
            "tools: gpiomon - single rising edge event",
            0, { 8, 8 });
+
+static void gpiomon_single_rising_edge_event_silent(void)
+{
+       test_tool_run("gpiomon", "--rising-edge", "--num-events=1",
+                     "--silent", test_chip_name(1), "4", (char *)NULL);
+       test_set_event(1, 4, TEST_EVENT_RISING, 200);
+       test_tool_wait();
+
+       TEST_ASSERT(test_tool_exited());
+       TEST_ASSERT_RET_OK(test_tool_exit_status());
+       TEST_ASSERT_NULL(test_tool_stdout());
+       TEST_ASSERT_NULL(test_tool_stderr());
+}
+TEST_DEFINE(gpiomon_single_rising_edge_event_silent,
+           "tools: gpiomon - single rising edge event (silent mode)",
+           0, { 8, 8 });
+
+static void gpiomon_four_alternating_events(void)
+{
+       test_tool_run("gpiomon", "--num-events=4",
+                     test_chip_name(1), "4", (char *)NULL);
+       test_set_event(1, 4, TEST_EVENT_ALTERNATING, 100);
+       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_NULL(test_tool_stderr());
+       TEST_ASSERT_REGEX_MATCH(test_tool_stdout(),
+                               "FALLING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[[0-9]+\\.[0-9]+\\]");
+       TEST_ASSERT_REGEX_MATCH(test_tool_stdout(),
+                               "RISING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[[0-9]+\\.[0-9]+\\]");
+}
+TEST_DEFINE(gpiomon_four_alternating_events,
+           "tools: gpiomon - four alternating events",
+           0, { 8, 8 });