mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-17 02:15:02 +00:00
test/py: Rework how test_ums.py handles (not) having write enabled
With a newer pylint version we get a warning about how mounted_test_fn could be used before assignment. Evaluating the code, this can't happen because we check for "not have_writable_fs_partition" and return before moving to the part of the tests which use mounted_test_fn. However, we should instead have this written so that we only try this part of the test if have_writable_fs_partition is set, and this also fixes the warning. As part of this we also move test_f and mounted_test_fn to the section of code that already only does this if have_writable_fs_partition is set. Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
3e335ddca6
commit
203d3a9fc7
1 changed files with 18 additions and 22 deletions
|
@ -113,14 +113,12 @@ def test_ums(u_boot_console, env__usb_dev_port, env__block_devs):
|
||||||
mount_subdir = env__block_devs[0]['writable_fs_subdir']
|
mount_subdir = env__block_devs[0]['writable_fs_subdir']
|
||||||
part_num = env__block_devs[0]['writable_fs_partition']
|
part_num = env__block_devs[0]['writable_fs_partition']
|
||||||
host_ums_part_node = '%s-part%d' % (host_ums_dev_node, part_num)
|
host_ums_part_node = '%s-part%d' % (host_ums_dev_node, part_num)
|
||||||
|
test_f = u_boot_utils.PersistentRandomFile(u_boot_console, 'ums.bin',
|
||||||
|
1024 * 1024);
|
||||||
|
mounted_test_fn = mount_point + '/' + mount_subdir + test_f.fn
|
||||||
else:
|
else:
|
||||||
host_ums_part_node = host_ums_dev_node
|
host_ums_part_node = host_ums_dev_node
|
||||||
|
|
||||||
test_f = u_boot_utils.PersistentRandomFile(u_boot_console, 'ums.bin',
|
|
||||||
1024 * 1024);
|
|
||||||
if have_writable_fs_partition:
|
|
||||||
mounted_test_fn = mount_point + '/' + mount_subdir + test_f.fn
|
|
||||||
|
|
||||||
def start_ums():
|
def start_ums():
|
||||||
"""Start U-Boot's ums shell command.
|
"""Start U-Boot's ums shell command.
|
||||||
|
|
||||||
|
@ -197,25 +195,23 @@ def test_ums(u_boot_console, env__usb_dev_port, env__block_devs):
|
||||||
ignore_errors)
|
ignore_errors)
|
||||||
|
|
||||||
ignore_cleanup_errors = True
|
ignore_cleanup_errors = True
|
||||||
try:
|
if have_writable_fs_partition:
|
||||||
start_ums()
|
|
||||||
if not have_writable_fs_partition:
|
|
||||||
# Skip filesystem-based testing if not configured
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
mount()
|
start_ums()
|
||||||
u_boot_console.log.action('Writing test file via UMS')
|
try:
|
||||||
cmd = ('rm', '-f', mounted_test_fn)
|
mount()
|
||||||
u_boot_utils.run_and_log(u_boot_console, cmd)
|
u_boot_console.log.action('Writing test file via UMS')
|
||||||
if os.path.exists(mounted_test_fn):
|
cmd = ('rm', '-f', mounted_test_fn)
|
||||||
raise Exception('Could not rm target UMS test file')
|
u_boot_utils.run_and_log(u_boot_console, cmd)
|
||||||
cmd = ('cp', test_f.abs_fn, mounted_test_fn)
|
if os.path.exists(mounted_test_fn):
|
||||||
u_boot_utils.run_and_log(u_boot_console, cmd)
|
raise Exception('Could not rm target UMS test file')
|
||||||
ignore_cleanup_errors = False
|
cmd = ('cp', test_f.abs_fn, mounted_test_fn)
|
||||||
|
u_boot_utils.run_and_log(u_boot_console, cmd)
|
||||||
|
ignore_cleanup_errors = False
|
||||||
|
finally:
|
||||||
|
umount(ignore_errors=ignore_cleanup_errors)
|
||||||
finally:
|
finally:
|
||||||
umount(ignore_errors=ignore_cleanup_errors)
|
stop_ums(ignore_errors=ignore_cleanup_errors)
|
||||||
finally:
|
|
||||||
stop_ums(ignore_errors=ignore_cleanup_errors)
|
|
||||||
|
|
||||||
ignore_cleanup_errors = True
|
ignore_cleanup_errors = True
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue