Re: [libgpiod] [PATCH 04/19] tests: add tests for bias flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 18, 2019 at 02:51:17PM +0100, Bartosz Golaszewski wrote:
> pt., 15 lis 2019 o 15:44 Kent Gibson <warthog618@xxxxxxxxx> napisał(a):
> >
> > Extend test coverage over the bias flags, gpiod_line_bias and the extended
> > ctxless functions.
> >
> > Also update existing tests to check bias flags where line state is checked.
> >
> > Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx>
> > ---
> >  tests/tests-ctxless.c |  64 +++++++++++++++++++++-
> >  tests/tests-event.c   | 120 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/tests-line.c    |  98 ++++++++++++++++++++++++++++++++++
> >  3 files changed, 280 insertions(+), 2 deletions(-)
> >
> > diff --git a/tests/tests-ctxless.c b/tests/tests-ctxless.c
> > index c1e1ca6..da70587 100644
> > --- a/tests/tests-ctxless.c
> > +++ b/tests/tests-ctxless.c
> > @@ -26,11 +26,41 @@ GPIOD_TEST_CASE(get_value, 0, { 8 })
> >         g_assert_cmpint(ret, ==, 1);
> >  }
> >
> > -static void set_value_check(gpointer data G_GNUC_UNUSED)
> > +GPIOD_TEST_CASE(get_value_ext, 0, { 8 })
> > +{
> > +       gint ret;
> > +
> > +       ret = gpiod_ctxless_get_value_ext(gpiod_test_chip_name(0), 3,
> > +                               false, GPIOD_CTXLESS_FLAG_BIAS_PULL_DOWN,
> > +                               GPIOD_TEST_CONSUMER);
> > +       g_assert_cmpint(ret, ==, 0);
> > +
> > +       ret = gpiod_ctxless_get_value_ext(gpiod_test_chip_name(0), 3,
> > +                               false, GPIOD_CTXLESS_FLAG_BIAS_PULL_UP,
> > +                               GPIOD_TEST_CONSUMER);
> > +       g_assert_cmpint(ret, ==, 1);
> > +
> > +       ret = gpiod_ctxless_get_value_ext(gpiod_test_chip_name(0), 3,
> > +                               true, GPIOD_CTXLESS_FLAG_BIAS_PULL_DOWN,
> > +                               GPIOD_TEST_CONSUMER);
> > +       g_assert_cmpint(ret, ==, 1);
> > +
> > +       ret = gpiod_ctxless_get_value_ext(gpiod_test_chip_name(0), 3,
> > +                               true, GPIOD_CTXLESS_FLAG_BIAS_PULL_UP,
> > +                               GPIOD_TEST_CONSUMER);
> > +       g_assert_cmpint(ret, ==, 0);
> > +}
> > +
> > +static void set_value_check_hi(gpointer data G_GNUC_UNUSED)
> >  {
> >         g_assert_cmpint(gpiod_test_chip_get_value(0, 3), ==, 1);
> >  }
> >
> > +static void set_value_check_lo(gpointer data G_GNUC_UNUSED)
> > +{
> > +       g_assert_cmpint(gpiod_test_chip_get_value(0, 3), ==, 0);
> > +}
> > +
> >  GPIOD_TEST_CASE(set_value, 0, { 8 })
> >  {
> >         gint ret;
> > @@ -39,13 +69,43 @@ GPIOD_TEST_CASE(set_value, 0, { 8 })
> >
> >         ret = gpiod_ctxless_set_value(gpiod_test_chip_name(0), 3, 1,
> >                                       false, GPIOD_TEST_CONSUMER,
> > -                                     set_value_check, NULL);
> > +                                     set_value_check_hi, NULL);
> >         gpiod_test_return_if_failed();
> >         g_assert_cmpint(ret, ==, 0);
> >
> >         g_assert_cmpint(gpiod_test_chip_get_value(0, 3), ==, 0);
> >  }
> >
> > +GPIOD_TEST_CASE(set_value_ext, 0, { 8 })
> > +{
> > +       gint ret;
> > +
> > +       gpiod_test_chip_set_pull(0, 3, 0);
> > +
> > +       ret = gpiod_ctxless_set_value_ext(gpiod_test_chip_name(0), 3, 1,
> > +                       false, 0, GPIOD_TEST_CONSUMER,
> > +                       set_value_check_hi, NULL);
> > +       gpiod_test_return_if_failed();
> > +       g_assert_cmpint(ret, ==, 0);
> > +       g_assert_cmpint(gpiod_test_chip_get_value(0, 3), ==, 0);
> > +
> > +       // test drive flags by checking that sets are caught by emulation
> 
> Nit: don't use C++ comments in libgpiod.
> 

Sorry - old habits.

Kent.




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux