From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] test/py: make each unit test a pytest
Date: Tue, 2 Feb 2016 12:43:15 -0700 [thread overview]
Message-ID: <56B106D3.2000005@wwwdotorg.org> (raw)
In-Reply-To: <CAPnjgZ1qs2AdtcqzH5R5KTboZfwFm6P4y-vChXavzdm-Z6u-vw@mail.gmail.com>
On 01/29/2016 01:11 PM, Simon Glass wrote:
> Hi Stephen,
>
> On 29 January 2016 at 11:48, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> On 01/29/2016 11:23 AM, Simon Glass wrote:
>>>
>>> Hi Stephen,
>>>
>>> On 28 January 2016 at 22:08, Stephen Warren <swarren@wwwdotorg.org> wrote:
>>>>
>>>> On 01/28/2016 08:52 PM, Simon Glass wrote:
>>>>>
>>>>> Hi Stephen,
>>>>>
>>>>> On 28 January 2016 at 16:45, Stephen Warren <swarren@wwwdotorg.org>
>>>>> wrote:
>>>>>>
>>>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>>>
>>>>>> A custom fixture named ut_subtest is implemented which is parametrized
>>>>>> with the names of all unit tests that the U-Boot binary supports. This
>>>>>> causes each U-Boot unit test to be exposes as a separate pytest. In
>>>>>> turn,
>>>>>> this allows more fine-grained pass/fail counts and test selection,
>>>>>> e.g.:
>>>>>>
>>>>>> test.py --bd sandbox -k ut_dm_usb
>>>>>>
>>>>>> ... will run about 8 tests at present.
>>>>>>
>>>>>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>>>>>> ---
>>>>>> This depends on at least my recently sent "test/py: run C-based unit
>>>>>> tests".
>>>>>>
>>>>>> test/py/conftest.py | 105
>>>>>> ++++++++++++++++++++++++++++++++++++-----------
>>>>>> test/py/tests/test_ut.py | 14 +++----
>>>>>> 2 files changed, 86 insertions(+), 33 deletions(-)
>>>>>
>>>>>
>>>>> This seems a bit extreme. It might be better to move the remaining
>>>>> three commands under the 'ut' subcommand. Then all unit tests would be
>>>>> visible from the 'ut' help...
>>>>
>>>>
>>>> I'm not sure what you mean by "extreme"? Do you mean you don't want each
>>>> unit test exposed as a separate pytest? I thought based on our previous
>>>> conversation that was exactly what you wanted. If not, I'm not sure what
>>>> the deficiency in the current code is; either all the dm subtests are
>>>> executed at once by a single pytest with a single overall status, or
>>>> they're each a separate pytest with individual status. Any grouping
>>>> that's in between those seems like it would be entirely arbitrary?
>>>
>>>
>>> I mean that there might be a simpler way to find out what unit tests
>>> are available in U-Boot rather than using objdump! Can the 'ut'
>>> command itself report this?
>>
>>
>> Well, the Python code could parse the ELF binary itself... :-)
>
> Eek!
>
>> We can't parse the source code to determine the test list, since it'd be
>> hard to determine which tests were actually compiled in (based on .config
>> feature support), v.s. which were simply written but not compiled.
>>
>> Perhaps we could add a new command-line option to U-Boot that /only/ prints
>> out the list of support unit tests. That would mean executing the U-Boot
>> binary on the host to determine the list though, which would limit the
>> approach to sandbox; it couldn't ever work if we enabled unit tests on real
>> HW. objdump should work in that scenario.
>
> That was what I was thinking actually. The 'ut' command already prints
> a list when given no args, but you could add 'ut list'.
>
> I'm not quite clear how useful the 'ut' tests are on real hardware.
> They are seldom enabled. Do you actually parse the U-Boot binary for
> the board?
There's no other place in the test system that parses the U-Boot binary.
>> Or perhaps the build process could dump out a list of enabled unit tests, so
>> test/py could simply read that file. At least that would push the objdump
>> usage into the build process where it's basically guaranteed we have an
>> objdump binary, plus we can use $(CROSS_COMPILE)objdump which would be
>> better for cross-compiled binaries...
>
> Or do you think it would be acceptable to just have a hard-coded list
> of tests and try each one?
>
> Or maybe your current approach is better than the alternatives...
Overall, I still like the idea of simply parsing the binary best.
I see no reason why (at least some subset of) unit tests could not ever
be enabled in non-sandbox builds. So, I'd like the test system not to
assume that they won't be. This means we can't execute the binary to
find out the list of enabled tests beforehand, since determining the
list has to happen before we run any tests, and hence happen via code on
the host machine, which can't run target binaries.
One improvement I can make is to run the objdump during the build
process. As part of generating u-boot and u-boot.map, we can also call
objdump to generate u-boot.syms. This isolates use of "compiler" tools
like objdump to the Makefile; a more typical place to run them. The
parsing of u-boot.syms can be left up to the test scripts.
prev parent reply other threads:[~2016-02-02 19:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-28 23:45 [U-Boot] [PATCH] test/py: make each unit test a pytest Stephen Warren
2016-01-29 3:52 ` Simon Glass
2016-01-29 5:08 ` Stephen Warren
2016-01-29 18:23 ` Simon Glass
2016-01-29 18:48 ` Stephen Warren
2016-01-29 20:11 ` Simon Glass
2016-02-02 19:43 ` Stephen Warren [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=56B106D3.2000005@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--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