tests: gpiomon: test a single rising edge event
authorBartosz Golaszewski <bartekgola@gmail.com>
Wed, 14 Jun 2017 07:55:58 +0000 (09:55 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Wed, 14 Jun 2017 07:55:58 +0000 (09:55 +0200)
Add a simple test case checking if gpiomon can receive a single rising
edge event.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
tests/Makefile.am
tests/tests-gpiomon.c [new file with mode: 0644]

index 2508465bb5bfa503d46be3e64de9fb560faa9c2b..0cdf336d7d2603427412a124ded96a7ce2202931 100644 (file)
@@ -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 (file)
index 0000000..ad5f846
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Test cases for the gpiomon tool.
+ *
+ * Copyright (C) 2017 Bartosz Golaszewski <bartekgola@gmail.com>
+ *
+ * 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 });