From 8bba443fbc00794c4eab867f7c79dd1de5ce56b6 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 12 Jun 2017 21:38:04 +0200 Subject: [PATCH] tests: add a simple test case for gpioset Verify the 'exit' mode of gpioset. Signed-off-by: Bartosz Golaszewski --- tests/Makefile.am | 3 ++- tests/tests-gpioset.c | 52 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/tests-gpioset.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 49d7e25..2508465 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,7 +27,8 @@ if WITH_TOOLS gpiod_test_SOURCES += tests-gpiodetect.c \ tests-gpiofind.c \ tests-gpioget.c \ - tests-gpioinfo.c + tests-gpioinfo.c \ + tests-gpioset.c endif diff --git a/tests/tests-gpioset.c b/tests/tests-gpioset.c new file mode 100644 index 0000000..29f3e61 --- /dev/null +++ b/tests/tests-gpioset.c @@ -0,0 +1,52 @@ +/* + * Test cases for the gpioset 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 gpioset_set_lines_and_exit(void) +{ + unsigned int offsets[8]; + int rv, values[8]; + + test_tool_run("gpioset", "gpiochip2", + "0=0", "1=0", "2=1", "3=1", + "4=1", "5=1", "6=0", "7=1", (char *)NULL); + 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] = 0; + offsets[1] = 1; + offsets[2] = 2; + offsets[3] = 3; + offsets[4] = 4; + offsets[5] = 5; + offsets[6] = 6; + offsets[7] = 7; + + rv = gpiod_simple_get_value_multiple(TEST_CONSUMER, test_chip_name(2), + offsets, values, 8, false); + TEST_ASSERT_RET_OK(rv); + + TEST_ASSERT_EQ(values[0], 0); + TEST_ASSERT_EQ(values[1], 0); + TEST_ASSERT_EQ(values[2], 1); + TEST_ASSERT_EQ(values[3], 1); + TEST_ASSERT_EQ(values[4], 1); + TEST_ASSERT_EQ(values[5], 1); + TEST_ASSERT_EQ(values[6], 0); + TEST_ASSERT_EQ(values[7], 1); +} +TEST_DEFINE(gpioset_set_lines_and_exit, + "tools: gpioset - set lines and exit", + 0, { 8, 8, 8 }); -- 2.30.2