Message ID | 1428512810-21566-5-git-send-email-p.marczak@samsung.com |
---|---|
State | Superseded |
Delegated to: | Simon Glass |
Headers | show |
On 8 April 2015 at 11:06, Przemyslaw Marczak <p.marczak@samsung.com> wrote: > This commit introduces simple tests for functions: > - uclass_find_first_device() > - uclass_find_next_device() > - uclass_first_device() > - uclass_next_device() > > Tests added by this commit: > - Test: dm_test_uclass_devices_find: > * call uclass_find_first_device(), then check if: (dev != NULL), (ret == 0) > * for the rest devices, call uclass_find_next_device() and do the same check > > - Test: dm_test_uclass_devices_get: > * call uclass_first_device(), then check if: > -- (dev != NULL), (ret == 0), device_active() > * for the rest devices, call uclass_next_device() and do the same check > > Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> > Cc: Simon Glass <sjg@chromium.org> > > Changes V3: > - new commit > --- > test/dm/core.c | 34 +++++++++++++++++++++++++++++++++- > 1 file changed, 33 insertions(+), 1 deletion(-) Acked-by: Simon Glass <sjg@chromium.org> See below. > > diff --git a/test/dm/core.c b/test/dm/core.c > index 009ad36..3a8dd1d 100644 > --- a/test/dm/core.c > +++ b/test/dm/core.c > @@ -656,9 +656,41 @@ static int dm_test_uclass_before_ready(struct dm_test_state *dms) > > return 0; > } > - > DM_TEST(dm_test_uclass_before_ready, 0); > > +static int dm_test_uclass_devices_find(struct dm_test_state *dms) > +{ > + struct udevice *dev; > + int ret; > + > + for (ret = uclass_find_first_device(UCLASS_TEST, &dev); > + dev; > + ret = uclass_find_next_device(&dev)) { > + ut_assert(!ret); > + ut_assert(dev); ut_assert(!device_active(dev)); If you like I can add that when I apply. > + } > + > + return 0; > +} > +DM_TEST(dm_test_uclass_devices_find, DM_TESTF_SCAN_PDATA); > + > +static int dm_test_uclass_devices_get(struct dm_test_state *dms) > +{ > + struct udevice *dev; > + int ret; > + > + for (ret = uclass_first_device(UCLASS_TEST, &dev); > + dev; > + ret = uclass_next_device(&dev)) { > + ut_assert(!ret); > + ut_assert(dev); > + ut_assert(device_active(dev)); > + } > + > + return 0; > +} > +DM_TEST(dm_test_uclass_devices_get, DM_TESTF_SCAN_PDATA); > + > static int dm_test_device_get_uclass_id(struct dm_test_state *dms) > { > struct udevice *dev; > -- > 1.9.1 > Regards, Simon
Hello Simon, On 04/09/2015 03:47 AM, Simon Glass wrote: > On 8 April 2015 at 11:06, Przemyslaw Marczak <p.marczak@samsung.com> wrote: >> This commit introduces simple tests for functions: >> - uclass_find_first_device() >> - uclass_find_next_device() >> - uclass_first_device() >> - uclass_next_device() >> >> Tests added by this commit: >> - Test: dm_test_uclass_devices_find: >> * call uclass_find_first_device(), then check if: (dev != NULL), (ret == 0) >> * for the rest devices, call uclass_find_next_device() and do the same check >> >> - Test: dm_test_uclass_devices_get: >> * call uclass_first_device(), then check if: >> -- (dev != NULL), (ret == 0), device_active() >> * for the rest devices, call uclass_next_device() and do the same check >> >> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> >> Cc: Simon Glass <sjg@chromium.org> >> >> Changes V3: >> - new commit >> --- >> test/dm/core.c | 34 +++++++++++++++++++++++++++++++++- >> 1 file changed, 33 insertions(+), 1 deletion(-) > > Acked-by: Simon Glass <sjg@chromium.org> > > See below. > >> >> diff --git a/test/dm/core.c b/test/dm/core.c >> index 009ad36..3a8dd1d 100644 >> --- a/test/dm/core.c >> +++ b/test/dm/core.c >> @@ -656,9 +656,41 @@ static int dm_test_uclass_before_ready(struct dm_test_state *dms) >> >> return 0; >> } >> - >> DM_TEST(dm_test_uclass_before_ready, 0); >> >> +static int dm_test_uclass_devices_find(struct dm_test_state *dms) >> +{ >> + struct udevice *dev; >> + int ret; >> + >> + for (ret = uclass_find_first_device(UCLASS_TEST, &dev); >> + dev; >> + ret = uclass_find_next_device(&dev)) { >> + ut_assert(!ret); >> + ut_assert(dev); > > ut_assert(!device_active(dev)); > > If you like I can add that when I apply. > I don't think it's a good idea. Those calls above, don't probe the device, but also don't guarantee that, the returned device was not probed, before the call. >> + } >> + >> + return 0; >> +} >> +DM_TEST(dm_test_uclass_devices_find, DM_TESTF_SCAN_PDATA); >> + >> +static int dm_test_uclass_devices_get(struct dm_test_state *dms) >> +{ >> + struct udevice *dev; >> + int ret; >> + >> + for (ret = uclass_first_device(UCLASS_TEST, &dev); >> + dev; >> + ret = uclass_next_device(&dev)) { >> + ut_assert(!ret); >> + ut_assert(dev); >> + ut_assert(device_active(dev)); >> + } >> + >> + return 0; >> +} >> +DM_TEST(dm_test_uclass_devices_get, DM_TESTF_SCAN_PDATA); >> + >> static int dm_test_device_get_uclass_id(struct dm_test_state *dms) >> { >> struct udevice *dev; >> -- >> 1.9.1 >> > > Regards, > Simon > Best regards,
diff --git a/test/dm/core.c b/test/dm/core.c index 009ad36..3a8dd1d 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -656,9 +656,41 @@ static int dm_test_uclass_before_ready(struct dm_test_state *dms) return 0; } - DM_TEST(dm_test_uclass_before_ready, 0); +static int dm_test_uclass_devices_find(struct dm_test_state *dms) +{ + struct udevice *dev; + int ret; + + for (ret = uclass_find_first_device(UCLASS_TEST, &dev); + dev; + ret = uclass_find_next_device(&dev)) { + ut_assert(!ret); + ut_assert(dev); + } + + return 0; +} +DM_TEST(dm_test_uclass_devices_find, DM_TESTF_SCAN_PDATA); + +static int dm_test_uclass_devices_get(struct dm_test_state *dms) +{ + struct udevice *dev; + int ret; + + for (ret = uclass_first_device(UCLASS_TEST, &dev); + dev; + ret = uclass_next_device(&dev)) { + ut_assert(!ret); + ut_assert(dev); + ut_assert(device_active(dev)); + } + + return 0; +} +DM_TEST(dm_test_uclass_devices_get, DM_TESTF_SCAN_PDATA); + static int dm_test_device_get_uclass_id(struct dm_test_state *dms) { struct udevice *dev;
This commit introduces simple tests for functions: - uclass_find_first_device() - uclass_find_next_device() - uclass_first_device() - uclass_next_device() Tests added by this commit: - Test: dm_test_uclass_devices_find: * call uclass_find_first_device(), then check if: (dev != NULL), (ret == 0) * for the rest devices, call uclass_find_next_device() and do the same check - Test: dm_test_uclass_devices_get: * call uclass_first_device(), then check if: -- (dev != NULL), (ret == 0), device_active() * for the rest devices, call uclass_next_device() and do the same check Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Simon Glass <sjg@chromium.org> Changes V3: - new commit --- test/dm/core.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)