[U-Boot] [PATCH v2 1/3] tests: py: dfu: Add global variables to store dfu alt numbers for test and dummy files

Lukasz Majewski l.majewski at samsung.com
Tue Apr 19 17:51:22 CEST 2016


This patch replaces hardcoded (i.e. 0 and 1) values passed to dfu_{read|write}
with global variables.

Signed-off-by: Lukasz Majewski <l.majewski at samsung.com>
---
Changes for v2:
- None
---
 test/py/tests/test_dfu.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/test/py/tests/test_dfu.py b/test/py/tests/test_dfu.py
index 093e8d0..df3b561 100644
--- a/test/py/tests/test_dfu.py
+++ b/test/py/tests/test_dfu.py
@@ -80,6 +80,10 @@ test_sizes_default = (
 
 first_usb_dev_port = None
 
+# Default alt settings for test and dummy files
+alt_setting_test_file = 0
+alt_setting_dummy_file = 1
+
 @pytest.mark.buildconfigspec('cmd_dfu')
 def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
     """Test the "dfu" command; the host system must be able to enumerate a USB
@@ -229,15 +233,15 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
 
         u_boot_console.log.action('Writing test data to DFU primary ' +
             'altsetting')
-        dfu_write(0, test_f.abs_fn)
+        dfu_write(alt_setting_test_file, test_f.abs_fn)
 
         u_boot_console.log.action('Writing dummy data to DFU secondary ' +
             'altsetting to clear DFU buffers')
-        dfu_write(1, dummy_f.abs_fn)
+        dfu_write(alt_setting_dummy_file, dummy_f.abs_fn)
 
         u_boot_console.log.action('Reading DFU primary altsetting for ' +
             'comparison')
-        dfu_read(0, readback_fn)
+        dfu_read(alt_setting_test_file, readback_fn)
 
         u_boot_console.log.action('Comparing written and read data')
         written_hash = test_f.content_hash
@@ -266,7 +270,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
 
         u_boot_console.log.action(
             'Overwriting DFU primary altsetting with dummy data')
-        dfu_write(0, dummy_f.abs_fn)
+        dfu_write(alt_setting_test_file, dummy_f.abs_fn)
 
         for size in sizes:
             with u_boot_console.log.section('Data size %d' % size):
-- 
2.0.0.rc2



More information about the U-Boot mailing list