diff mbox

[U-Boot,v2,29/32] dm: usb: Clean up USB after each test

Message ID 1456784765-10788-30-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Feb. 29, 2016, 10:26 p.m. UTC
The USB subsystem has a few counters that need to be reset since they are
stored in static variables rather than driver-model data. An example is
usb_max_devs. Ultimately we should move this data into the USB uclass.

For now, make sure that USB is reset after each test, so that the counters
go back to zero.

Note: this is not a perfect solution: It a USB test fails it will exit
immediately and leave USB un-reset. The impact here is that it may cause
subsequence test failures in the same run.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 test/dm/usb.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Simon Glass March 13, 2016, 1:53 a.m. UTC | #1
On 29 February 2016 at 15:26, Simon Glass <sjg@chromium.org> wrote:
> The USB subsystem has a few counters that need to be reset since they are
> stored in static variables rather than driver-model data. An example is
> usb_max_devs. Ultimately we should move this data into the USB uclass.
>
> For now, make sure that USB is reset after each test, so that the counters
> go back to zero.
>
> Note: this is not a perfect solution: It a USB test fails it will exit
> immediately and leave USB un-reset. The impact here is that it may cause
> subsequence test failures in the same run.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
>  test/dm/usb.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied to u-boot-dm/next.
diff mbox

Patch

diff --git a/test/dm/usb.c b/test/dm/usb.c
index 2d20354..b46ae60 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -52,6 +52,7 @@  static int dm_test_usb_flash(struct unit_test_state *uts)
 	memset(cmp, '\0', sizeof(cmp));
 	ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp));
 	ut_assertok(strcmp(cmp, "this is a test"));
+	ut_assertok(usb_stop());
 
 	return 0;
 }
@@ -67,6 +68,7 @@  static int dm_test_usb_multi(struct unit_test_state *uts)
 	ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &dev));
 	ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 1, &dev));
 	ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 2, &dev));
+	ut_assertok(usb_stop());
 
 	return 0;
 }