From: Kent Gibson <warthog618@gmail.com>
To: linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, ml@ionscale.com
Cc: Kent Gibson <warthog618@gmail.com>
Subject: [PATCH 1/3] bindings: cxx: tests: add tests for bulk events get_values
Date: Wed, 17 Jun 2020 11:06:37 +0800 [thread overview]
Message-ID: <20200617030639.27690-2-warthog618@gmail.com> (raw)
In-Reply-To: <20200617030639.27690-1-warthog618@gmail.com>
Add tests to verify the behaviour of get_values when applied to a bulk
of event lines.
Reported-by: Gerrit Wyen <ml@ionscale.com>
Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
The reported behaviour is that only the first line value is returned correctly.
The tests verify that behaviour in v1.5.
bindings/cxx/tests/tests-event.cpp | 36 +++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/bindings/cxx/tests/tests-event.cpp b/bindings/cxx/tests/tests-event.cpp
index 63b6cc5..6d1c069 100644
--- a/bindings/cxx/tests/tests-event.cpp
+++ b/bindings/cxx/tests/tests-event.cpp
@@ -193,7 +193,7 @@ TEST_CASE("Event file descriptors can be used for polling", "[event]")
}
}
-TEST_CASE("It's possible to read values from lines requested for events", "[event][line]")
+TEST_CASE("It's possible to read a value from a line requested for events", "[event][line]")
{
mockup::probe_guard mockup_chips({ 8 });
::gpiod::chip chip(mockup::instance().chip_name(0));
@@ -219,6 +219,40 @@ TEST_CASE("It's possible to read values from lines requested for events", "[even
}
}
+TEST_CASE("It's possible to read values from lines requested for events", "[event][bulk]")
+{
+ mockup::probe_guard mockup_chips({ 8 });
+ ::gpiod::chip chip(mockup::instance().chip_name(0));
+ auto lines = chip.get_lines({ 0, 1, 2, 3, 4 });
+ ::gpiod::line_request config;
+
+ config.consumer = consumer.c_str();
+ config.request_type = ::gpiod::line_request::EVENT_BOTH_EDGES;
+
+ mockup::instance().chip_set_pull(0, 5, 1);
+
+ SECTION("active-high (default)")
+ {
+ lines.request(config);
+ REQUIRE(lines.get_values() == ::std::vector<int>({ 0, 0, 0, 0, 0 }));
+ mockup::instance().chip_set_pull(0, 1, 1);
+ mockup::instance().chip_set_pull(0, 3, 1);
+ mockup::instance().chip_set_pull(0, 4, 1);
+ REQUIRE(lines.get_values() == ::std::vector<int>({ 0, 1, 0, 1, 1 }));
+ }
+
+ SECTION("active-low")
+ {
+ config.flags = ::gpiod::line_request::FLAG_ACTIVE_LOW;
+ lines.request(config);
+ REQUIRE(lines.get_values() == ::std::vector<int>({ 1, 1, 1, 1, 1 }));
+ mockup::instance().chip_set_pull(0, 1, 1);
+ mockup::instance().chip_set_pull(0, 3, 1);
+ mockup::instance().chip_set_pull(0, 4, 1);
+ REQUIRE(lines.get_values() == ::std::vector<int>({ 1, 0, 1, 0, 0 }));
+ }
+}
+
TEST_CASE("It's possible to read more than one line event", "[event][line]")
{
mockup::probe_guard mockup_chips({ 8 });
--
2.27.0
next prev parent reply other threads:[~2020-06-17 3:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-17 3:06 [libgpiod][PATCH 0/3] fix get_values for events Kent Gibson
2020-06-17 3:06 ` Kent Gibson [this message]
2020-06-17 3:06 ` [PATCH 2/3] tests: event: add tests for gpiod_line_get_value_bulk events Kent Gibson
2020-06-17 3:06 ` [PATCH 3/3] core: fix gpiod_line_get_value_bulk for events Kent Gibson
2020-06-17 12:45 ` [libgpiod][PATCH 0/3] fix get_values " Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200617030639.27690-2-warthog618@gmail.com \
--to=warthog618@gmail.com \
--cc=bgolaszewski@baylibre.com \
--cc=linux-gpio@vger.kernel.org \
--cc=ml@ionscale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).