[U-Boot] [PATCH] test/py: gpt: make use of infra-structure

Stephen Warren swarren at wwwdotorg.org
Mon Sep 18 15:23:40 UTC 2017


On 09/16/2017 08:47 PM, Alison Chaiken wrote:
> I suggest that while we're cleaning this test up, that we add
> something like this to each of the tests:
> 
> diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py

> +    if not os.path.exists('/sbin/sgdisk'):
> +        pytest.skip('install gdisk package to test gpt commands')

I'd suggest doing that in a separate commit; my patch below already does 
enough things that it should probably be a series of smaller patches, 
and the change above probably applies to other tests as well.

> 
> Otherwise, the tests will all fail if the gdisk package is not
> installed.   Assuredly anyone who does not have gdisk installed does
> not care about these tests anyway.   If people agree, I can submit a
> patch, or perhaps Stephen could just add it to his.
> 
> Best wishes,
> Alison Chaiken
> Peloton Technology
> 
> On Fri, Sep 15, 2017 at 10:54 AM, Tom Rini <trini at konsulko.com> wrote:
>>
>> On Fri, Sep 15, 2017 at 11:25:51AM -0600, Stephen Warren wrote:
>>
>>> From: Stephen Warren <swarren at nvidia.com>
>>>
>>> Make various changes to the GPT test:
>>>
>>> 1) Reference the disk image using an absolute path in all cases. This
>>> allows test/py to operate correctly if it's run from a directory other
>>> than the root of the U-Boot source tree.
>>>
>>> 2) Store the disk image in the teswt/py persistent data directory. This
>>> removes the need to re-generate it every time the tests are run.
>>>
>>> 3) Execute sgdisk using u_boot_utils.run_and_log() so that its output is
>>> captured in the test log. This allows debugging any problems running it.
>>>
>>> 4) Make the disk image a test fixture. This removes the requirement to
>>> always run all GPT tests, and run them in order. The current code doesn't
>>> create the disk image if e.g. just test_gpt_uuid() is executed via the
>>> test.py -k command-line option.
>>>
>>> 5) Use @pytest.mark.buildconfigspec for all feature dependencies, rather
>>> than manually implementing some of them.
>>>
>>> Fixes: a2f422555fc8 ("add pytests for 'gpt guid' command in sandbox")
>>> Fixes: c5772188ede9 ("add pytests for 'gpt rename' and 'gpt swap'")
>>> Signed-off-by: Stephen Warren <swarren at nvidia.com>
>>
>> Having kicked my jenkins (sigh), and then really tried to run these
>> tests on hardware, I think we're not quite done:
>>
>>>   @pytest.mark.buildconfigspec('cmd_gpt')
>>> -def test_gpt_guid(u_boot_console):
>>> +def test_gpt_guid(state_disk_image, u_boot_console):
>>>       """Test the gpt guid command."""
>>>
>>> -    if u_boot_console.config.buildconfig.get('config_cmd_gpt', 'n') != 'y':
>>> -        pytest.skip('gpt command not supported')
>>> -    make_test_disk.makeDisk()
>>> -    u_boot_console.run_command('host bind 0 testdisk.raw')
>>> +    u_boot_console.run_command('host bind 0 ' + state_disk_image.path)
>>
>> Here and elsewhere we also need to say it depends on sandbox as that's
>> what gives the host command.  Thanks!
>>
>> --
>> Tom
> 



More information about the U-Boot mailing list