public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 02/10] test: pinmux: Add test for pin muxing
Date: Wed, 24 Jun 2020 16:32:34 -0400	[thread overview]
Message-ID: <ac4e71f7-1b2b-4d47-6756-427d85f769d6@gmail.com> (raw)
In-Reply-To: <CAPnjgZ0cmQjjORNKhdvoh7_LHVXWUG-weO1j-XPp8SS=YVi45g@mail.gmail.com>

On 6/24/20 9:45 AM, Simon Glass wrote:
> Hi Sean,
> 
> On Wed, 24 Jun 2020 at 02:01, Sean Anderson <seanga2@gmail.com> wrote:
>>
>> On 6/17/20 10:07 AM, Simon Glass wrote:
>>> Hi Sean,
>>>
>>> On Tue, 16 Jun 2020 at 21:18, Sean Anderson <seanga2@gmail.com> wrote:
>>>>
>>>> On 6/16/20 11:11 PM, Simon Glass wrote:
>>>>> Hi Sean,
>>>>>
>>>>> On Sun, 7 Jun 2020 at 19:27, Sean Anderson <seanga2@gmail.com> wrote:
>>>>>>
>>>>>> This extends the pinctrl-sandbox driver to support pin muxing, and adds a
>>>>>> test for that behaviour. The test is done in C and not python (like the
>>>>>> existing tests for the pinctrl uclass) because it needs to call
>>>>>> pinctrl_select_state.  Another option could be to add a command that
>>>>>> invokes pinctrl_select_state and then test everything in
>>>>>> test/py/tests/test_pinmux.py.
>>>>>>
>>>>>> The pinctrl-sandbox driver now mimics the way that many pinmux devices
>>>>>> work.  There are two groups of pins which are muxed together, as well as
>>>>>> four pins which are muxed individually. I have tried to test all normal
>>>>>> paths. However, very few error cases are explicitly checked for.
>>>>>>
>>>>>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>>>>>> ---
>>>>>>
>>>>>> Changes in v2:
>>>>>> - New
>>>>>>
>>>>>>  arch/sandbox/dts/test.dts         |  45 +++++++--
>>>>>>  drivers/pinctrl/pinctrl-sandbox.c | 155 +++++++++++++++++++++++-------
>>>>>>  test/dm/Makefile                  |   3 +
>>>>>>  test/py/tests/test_pinmux.py      |  36 +++----
>>>>>>  4 files changed, 178 insertions(+), 61 deletions(-)
>>>>>>
>>>>>
>>>>> [..]
>>>>>
>>>>>
>>>>>> diff --git a/test/dm/Makefile b/test/dm/Makefile
>>>>>> index 0d1c66fa1e..9e273ee02d 100644
>>>>>> --- a/test/dm/Makefile
>>>>>> +++ b/test/dm/Makefile
>>>>>> @@ -76,4 +76,7 @@ obj-$(CONFIG_DM_RNG) += rng.o
>>>>>>  obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o
>>>>>>  obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o
>>>>>>  obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o
>>>>>> +ifneq ($(CONFIG_PINMUX),)
>>>>>> +obj-$(CONFIG_PINCONF) += pinmux.o
>>>>>
>>>>> I don't see this file in your patch.
>>>>
>>>> Whoops, will add it next revision.
>>>>
>>>>>
>>>>>> +endif
>>>>>>  endif
>>>>>> diff --git a/test/py/tests/test_pinmux.py b/test/py/tests/test_pinmux.py
>>>>>> index 4e6df992a4..0cbbae000c 100644
>>>>>> --- a/test/py/tests/test_pinmux.py
>>>>>> +++ b/test/py/tests/test_pinmux.py
>>>>>> @@ -28,15 +28,15 @@ def test_pinmux_status_all(u_boot_console):
>>>>>
>>>>> Feel free to convert this to C also if you like. It is faster,
>>>>> although perhaps not much faster since it only runs a few commands?
>>>>
>>>> Ok, I can have a look.
>>>>
>>>> Should C be preferred for new tests?
>>>
>>> +Stephen Warren
>>>
>>> For sandbox tests, yes. If there is a lot of interaction, Python is
>>> extremely slow.
>>>
>>> But with Python we can run a test on real hardware without compiling
>>> the test into U-Boot. So there are benefits on both sides.
>>
>> Ok, I looked into it, and the python test uses the
>>     assert 'somestring' in output
>> idiom a lot. From what I can tell, there's not an easy way to replicate
>> this behavior on the C side of things. Adding a function to do this
>> would probably call for its own patch. I could also use the existing
>> functionality to test for lines, but I think that would be much more
>> brittle when compared to the python version.
> 
> Well you could add assert_nextline_contains() for example?

Yes, but I would also have to skip a specific number of lines, e.g.

console_record_reset();
run_command("pinmux", 0);
ut_assert_nextline_contains("");
ut_assert_nextline_contains("");
ut_assert_nextline_contains("Usage:");

console_record_reset();
/* ... */

That's ok, but still fairly brittle in how it tests the output.

Oh well, perhaps I'll add something like that next revision...

--Sean

  reply	other threads:[~2020-06-24 20:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08  1:26 [PATCH v2 00/10] riscv: Add FPIOA and GPIO support for Kendryte K210 Sean Anderson
2020-06-08  1:26 ` [PATCH v2 01/10] pinctrl: Add pinmux property support to pinctrl-generic Sean Anderson
2020-06-17  3:11   ` Simon Glass
2020-06-18  4:21     ` Sean Anderson
2020-06-08  1:26 ` [PATCH v2 02/10] test: pinmux: Add test for pin muxing Sean Anderson
2020-06-17  3:11   ` Simon Glass
2020-06-17  3:18     ` Sean Anderson
2020-06-17 14:07       ` Simon Glass
2020-06-24  8:01         ` Sean Anderson
2020-06-24 13:45           ` Simon Glass
2020-06-24 20:32             ` Sean Anderson [this message]
2020-06-08  1:26 ` [PATCH v2 03/10] pinctrl: Add support for Kendryte K210 FPIOA Sean Anderson
2020-06-08  1:26 ` [PATCH v2 04/10] gpio: sifive: Use generic reg read function Sean Anderson
2020-06-08  1:26 ` [PATCH v2 05/10] gpio: dw: Fix warnings about casting int to pointer Sean Anderson
2020-06-09  1:20   ` Tan, Ley Foon
2020-06-17  3:11   ` Simon Glass
2020-06-08  1:26 ` [PATCH v2 06/10] gpio: dw: Add a trailing underscore to generated name Sean Anderson
2020-06-08  1:26 ` [PATCH v2 07/10] gpio: dw: Return output value when direction is out Sean Anderson
2020-06-09  1:20   ` Tan, Ley Foon
2020-06-09  5:26   ` Sean Anderson
2020-06-08  1:26 ` [PATCH v2 08/10] led: gpio: Default to using node name if label is absent Sean Anderson
2020-06-17  3:11   ` Simon Glass
2020-06-17  3:18     ` Sean Anderson
2020-06-17 14:07       ` Simon Glass
2020-06-08  1:26 ` [PATCH v2 09/10] riscv: Add pinmux and gpio bindings for Kendryte K210 Sean Anderson
2020-06-08  1:26 ` [PATCH v2 10/10] riscv: Add FPIOA and GPIO support " Sean Anderson

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=ac4e71f7-1b2b-4d47-6756-427d85f769d6@gmail.com \
    --to=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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