tests: gpiomon: new test case for watching multiple lines
authorBartosz Golaszewski <bartekgola@gmail.com>
Fri, 23 Jun 2017 14:38:56 +0000 (16:38 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Fri, 23 Jun 2017 14:38:56 +0000 (16:38 +0200)
Make sure gpiomon behaves correctly when the requested line offsets
are not in order.

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

index 7d3ec5f10be77a719c2488c61068b9c03263e05e..b1337260bac7005a8e2f8fd7865e650c7d8c9e58 100644 (file)
@@ -175,6 +175,30 @@ TEST_DEFINE(gpiomon_watch_multiple_lines,
            "tools: gpiomon - watch multiple lines",
            0, { 8, 8 });
 
+static void gpiomon_watch_multiple_lines_not_in_order(void)
+{
+       test_tool_run("gpiomon", "--format=%o", test_chip_name(0),
+                     "5", "2", "7", "1", "6", (char *)NULL);
+       test_set_event(0, 2, TEST_EVENT_ALTERNATING, 100);
+       usleep(150000);
+       test_set_event(0, 1, TEST_EVENT_ALTERNATING, 100);
+       usleep(150000);
+       test_set_event(0, 6, TEST_EVENT_ALTERNATING, 100);
+       usleep(150000);
+       test_tool_signal(SIGTERM);
+       test_tool_wait();
+
+       TEST_ASSERT(test_tool_exited());
+       TEST_ASSERT_RET_OK(test_tool_exit_status());
+       TEST_ASSERT_NULL(test_tool_stderr());
+       TEST_ASSERT_NOT_NULL(test_tool_stdout());
+       TEST_ASSERT_STR_EQ(test_tool_stdout(), "2\n1\n6\n");
+
+}
+TEST_DEFINE(gpiomon_watch_multiple_lines_not_in_order,
+           "tools: gpiomon - watch multiple lines (offsets not in order)",
+           0, { 8, 8 });
+
 static void gpiomon_no_arguments(void)
 {
        test_tool_run("gpiomon", (char *)NULL);