[U-Boot] [PATCH 4/4 v2] dm: test: Add test for device removal

Stefan Roese sr at denx.de
Mon Mar 27 06:48:00 UTC 2017


Hi Simon,

On 26.03.2017 05:52, Simon Glass wrote:
> On 20 March 2017 at 05:51, Stefan Roese <sr at denx.de> wrote:
>> Add a test for the correct device removal. Currently two different ways
>> for device removal are supported:
>>
>> - Normal device removal via the device_remove() API
>> - Removal via selective device driver flags (DM_FLAG_ACTIVE_DMA)
>>
>> This new test "remove_active_dma" adds tests cases for those both ways
>> of removal.
>>
>> Signed-off-by: Stefan Roese <sr at denx.de>
>> Cc: Simon Glass <sjg at chromium.org>
>> ---
>> v2:
>> - New patch in patchset
>>
>>  test/dm/core.c        | 41 +++++++++++++++++++++++++++++++++++++++++
>>  test/dm/test-driver.c |  1 +
>>  2 files changed, 42 insertions(+)
>>
>> diff --git a/test/dm/core.c b/test/dm/core.c
>> index 07b2419ea4..ef85e6b79c 100644
>> --- a/test/dm/core.c
>> +++ b/test/dm/core.c
>> @@ -656,6 +656,47 @@ static int dm_test_pre_reloc(struct unit_test_state *uts)
>>  }
>>  DM_TEST(dm_test_pre_reloc, 0);
>>
>> +/*
>> + * Test that removal of devices, either via the "normal" device_remove()
>> + * API or via the device driver selective flag works as expected
>> + */
>> +static int dm_test_remove_active_dma(struct unit_test_state *uts)
>> +{
>> +       struct dm_test_state *dms = uts->priv;
>> +       struct udevice *dev;
>> +
>> +       ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
>> +                                       &dev));
>> +       ut_assert(dev);
>> +
>> +       /* Probe the device */
>> +       ut_assertok(device_probe(dev));
>> +
>> +       /* Test if device is active right now */
>> +       ut_asserteq(true, device_active(dev));
>> +
>> +       /* Remove the device via selective remove flag */
>> +       dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
>> +
>> +       /* Test if device is inactive right now */
>> +       ut_asserteq(false, device_active(dev));
>> +
>> +       /* Probe the device again */
>> +       ut_assertok(device_probe(dev));
>> +
>> +       /* Test if device is active right now */
>> +       ut_asserteq(true, device_active(dev));
>> +
>> +       /* Remove the device via "normal" remove API */
>> +       ut_assertok(device_remove(dev, DM_REMOVE_NORMAL));
>
> This doesn't actually test a device not getting removed (due to its
> flag) I think. Can you add a test for that?

Yes, I forgot to add a test for this "non-removal case". Will add
in the next version.

Thanks,
Stefan


More information about the U-Boot mailing list