From: Bartosz Golaszewski Date: Mon, 12 Jun 2017 20:04:04 +0000 (+0200) Subject: tests: gpioset: test the 'wait' mode X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=fe47480f954799b00d5c6e5a2c9ef83d8cd9da40;p=qemu-gpiodev%2Flibgpiod.git tests: gpioset: test the 'wait' mode Verify the behavior of gpioset in the 'wait' mode. Send a newline to gpioset's standard input and check if it correctly exits. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/tests-gpioset.c b/tests/tests-gpioset.c index 29f3e61..be43b3c 100644 --- a/tests/tests-gpioset.c +++ b/tests/tests-gpioset.c @@ -50,3 +50,38 @@ static void gpioset_set_lines_and_exit(void) TEST_DEFINE(gpioset_set_lines_and_exit, "tools: gpioset - set lines and exit", 0, { 8, 8, 8 }); + +static void gpioset_set_some_lines_and_wait_for_enter(void) +{ + unsigned int offsets[5]; + int rv, values[5]; + + test_tool_run("gpioset", "--mode=wait", "gpiochip2", + "1=0", "2=1", "5=1", "6=0", "7=1", (char *)NULL); + test_tool_stdin_write("\n"); + 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], 1); + TEST_ASSERT_EQ(values[3], 0); + TEST_ASSERT_EQ(values[4], 1); +} +TEST_DEFINE(gpioset_set_some_lines_and_wait_for_enter, + "tools: gpioset - set some lines and wait for enter", + 0, { 8, 8, 8 });