From: Bartosz Golaszewski Date: Tue, 13 Jun 2017 13:15:45 +0000 (+0200) Subject: tests: gpioset: test case for the 'signal' mode X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=6fb97c873da067be4fc528f19ffdaa981d67025a;p=qemu-gpiodev%2Flibgpiod.git tests: gpioset: test case for the 'signal' mode Run gpioset on a set of lines, give it a couple milliseconds to execute, then send it SIGTERM and check that it exits correctly. Repeat for SIGINT. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/tests-gpioset.c b/tests/tests-gpioset.c index 6636d33..89c1f50 100644 --- a/tests/tests-gpioset.c +++ b/tests/tests-gpioset.c @@ -10,6 +10,9 @@ #include "gpiod-test.h" +#include +#include + static void gpioset_set_lines_and_exit(void) { unsigned int offsets[8]; @@ -126,3 +129,45 @@ static void gpioset_set_some_lines_and_wait_for_enter(void) TEST_DEFINE(gpioset_set_some_lines_and_wait_for_enter, "tools: gpioset - set some lines and wait for enter", 0, { 8, 8, 8 }); + +static void gpioset_set_some_lines_and_wait_for_signal(void) +{ + static const int signals[] = { SIGTERM, SIGINT }; + + unsigned int offsets[5], i; + int rv, values[5]; + + for (i = 0; i < TEST_ARRAY_SIZE(signals); i++) { + test_tool_run("gpioset", "--mode=signal", "gpiochip2", + "1=0", "2=1", "5=0", "6=0", "7=1", (char *)NULL); + usleep(200000); + test_tool_signal(signals[i]); + 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()); + + offsets[0] = 1; + offsets[1] = 2; + offsets[2] = 5; + offsets[3] = 6; + offsets[4] = 7; + + rv = gpiod_simple_get_value_multiple(TEST_CONSUMER, + test_chip_name(2), + offsets, values, + 5, false); + TEST_ASSERT_RET_OK(rv); + + TEST_ASSERT_EQ(values[0], 0); + TEST_ASSERT_EQ(values[1], 1); + TEST_ASSERT_EQ(values[2], 0); + TEST_ASSERT_EQ(values[3], 0); + TEST_ASSERT_EQ(values[4], 1); + } +} +TEST_DEFINE(gpioset_set_some_lines_and_wait_for_signal, + "tools: gpioset - set some lines and wait for signal", + 0, { 8, 8, 8 });