From 66dc083969ec5177505c30cccc57261165139080 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Wed, 14 Jun 2017 09:55:58 +0200 Subject: [PATCH] tests: gpiomon: test a single rising edge event Add a simple test case checking if gpiomon can receive a single rising edge event. Signed-off-by: Bartosz Golaszewski --- tests/Makefile.am | 1 + tests/tests-gpiomon.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/tests-gpiomon.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 2508465..0cdf336 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,6 +28,7 @@ gpiod_test_SOURCES += tests-gpiodetect.c \ tests-gpiofind.c \ tests-gpioget.c \ tests-gpioinfo.c \ + tests-gpiomon.c \ tests-gpioset.c endif diff --git a/tests/tests-gpiomon.c b/tests/tests-gpiomon.c new file mode 100644 index 0000000..ad5f846 --- /dev/null +++ b/tests/tests-gpiomon.c @@ -0,0 +1,29 @@ +/* + * Test cases for the gpiomon tool. + * + * Copyright (C) 2017 Bartosz Golaszewski + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License + * as published by the Free Software Foundation. + */ + +#include "gpiod-test.h" + +static void gpiomon_single_rising_edge_event(void) +{ + test_tool_run("gpiomon", "--rising-edge", "--num-events=1", + 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_NOT_NULL(test_tool_stdout()); + TEST_ASSERT_NULL(test_tool_stderr()); + TEST_ASSERT_REGEX_MATCH(test_tool_stdout(), + "RISING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[[0-9]+\\.[0-9]+\\]"); +} +TEST_DEFINE(gpiomon_single_rising_edge_event, + "tools: gpiomon - single rising edge event", + 0, { 8, 8 }); -- 2.30.2