linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Chuang Zhu <chuang+git@melty.land>
Cc: linux-gpio@vger.kernel.org, Chuang Zhu <git@chuang.cz>
Subject: Re: [libgpiod][PATCH v2 1/2] bindings: python: tests: add a test case for line request by name with multiple entries
Date: Fri, 28 Jun 2024 18:31:18 +0800	[thread overview]
Message-ID: <20240628103118.GA56487@rigel> (raw)
In-Reply-To: <20240627153103.594107-1-chuang+git@melty.land>

On Thu, Jun 27, 2024 at 11:31:02PM +0800, Chuang Zhu wrote:
> From: Chuang Zhu <git@chuang.cz>
>

Add a commit comment.

> Signed-off-by: Chuang Zhu <git@chuang.cz>
> ---
>  bindings/python/tests/tests_line_request.py | 34 +++++++++++++++++++++
>  1 file changed, 34 insertions(+)
>
> diff --git a/bindings/python/tests/tests_line_request.py b/bindings/python/tests/tests_line_request.py
> index f99b93d..c9a5c81 100644
> --- a/bindings/python/tests/tests_line_request.py
> +++ b/bindings/python/tests/tests_line_request.py
> @@ -310,6 +310,40 @@ class LineRequestComplexConfig(TestCase):
>                  self.assertEqual(chip.get_line_info(3).edge_detection, Edge.BOTH)
>
>
> +class LineRequestComplexConfigByName(TestCase):

Nothing complex about the config, so LineRequestMixedConfigByName?

> +    def setUp(self):
> +        self.sim = gpiosim.Chip(num_lines=4, line_names={2: "foo", 3: "bar", 1: "baz", 0: "xyz"})
> +        self.req = gpiod.request_lines(
> +            self.sim.dev_path,
> +            {
> +                ("baz", "bar"): gpiod.LineSettings(direction=Direction.OUTPUT),
> +                ("foo", "xyz"): gpiod.LineSettings(direction=Direction.INPUT)
> +            },
> +        )
> +
> +    def tearDown(self):
> +        self.req.release()
> +        del self.req
> +        del self.sim
> +
> +    def test_set_values_by_name(self):
> +        self.req.set_values(
> +            {"bar": Value.ACTIVE, "baz": Value.INACTIVE}
> +        )
> +
> +        self.assertEqual(self.sim.get_value(1), SimVal.INACTIVE)
> +        self.assertEqual(self.sim.get_value(3), SimVal.ACTIVE)
> +
> +    def test_get_values_by_name(self):
> +        self.sim.set_pull(0, Pull.UP)
> +        self.sim.set_pull(2, Pull.DOWN)
> +
> +        self.assertEqual(
> +            self.req.get_values(["foo", "xyz"]),
> +            [Value.INACTIVE, Value.ACTIVE],
> +        )
> +

Add "baz" to the lines to get so this test fails as well - expected to
be INACTIVE.

Cheers,
Kent.

> +
>  class RepeatingLinesInRequestConfig(TestCase):
>      def setUp(self):
>          self.sim = gpiosim.Chip(num_lines=4, line_names={0: "foo", 2: "bar"})
> --
> 2.44.0
>

      parent reply	other threads:[~2024-06-28 10:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-27 15:31 [libgpiod][PATCH v2 1/2] bindings: python: tests: add a test case for line request by name with multiple entries Chuang Zhu
2024-06-27 15:31 ` [libgpiod][PATCH v2 2/2] bindings: python: fix " Chuang Zhu
2024-06-28 10:44   ` Kent Gibson
2024-06-28 10:31 ` Kent Gibson [this message]

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=20240628103118.GA56487@rigel \
    --to=warthog618@gmail.com \
    --cc=chuang+git@melty.land \
    --cc=git@chuang.cz \
    --cc=linux-gpio@vger.kernel.org \
    /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).