From e85d7f998a335091001d2ebd3fac81085e00e1c0 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Wed, 14 Jun 2017 10:37:56 +0200 Subject: [PATCH] tests: gpiomon: new test cases Add test cases verifying the --silent mode and receiving multiple events. Signed-off-by: Bartosz Golaszewski --- tests/tests-gpiomon.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/tests-gpiomon.c b/tests/tests-gpiomon.c index ad5f846..890c1a6 100644 --- a/tests/tests-gpiomon.c +++ b/tests/tests-gpiomon.c @@ -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 }); -- 2.30.2