From: Stephen Warren Date: Tue, 26 Jan 2016 17:59:43 +0000 (-0700) Subject: test/py: dfu: error out if USB device already exists X-Git-Tag: v2016.03-rc1~41^2~17 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=be1df82656b15663dee9216a320dc177c7d9c6c4;p=oweals%2Fu-boot.git test/py: dfu: error out if USB device already exists The DFU test requests U-Boot configure its USB controller in device mode, then waits for the host machine to enumerate the USB device and create a device node for it. However, this wait can be fooled if the USB device node already exists before the test starts, e.g. if some previous software stack already configured the USB controller into device mode and never de-configured it. This "previous software stack" could even be another test/py test, if U-Boot's own USB teardown does not operate correctly. If this happens, dfu-util may be run before U-Boot is ready to serve DFU commands, which may cause false test failures. Enhance the dfu test to fail if the device node exists before it is expected to. Signed-off-by: Stephen Warren Reviewed-by: Simon Glass --- diff --git a/test/py/tests/test_dfu.py b/test/py/tests/test_dfu.py index cc4b8d8e04..6c1a363b02 100644 --- a/test/py/tests/test_dfu.py +++ b/test/py/tests/test_dfu.py @@ -100,6 +100,12 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): Nothing. ''' + fh = u_boot_utils.attempt_to_open_file( + env__usb_dev_port['host_usb_dev_node']) + if fh: + fh.close() + raise Exception('USB device present before dfu command invoked') + u_boot_console.log.action( 'Starting long-running U-Boot dfu shell command')