From 06159a1465fc97d8d7b72b9bea39a396f6e7057c Mon Sep 17 00:00:00 2001 From: Gabriel Dalimonte Date: Mon, 17 Feb 2025 13:26:44 -0500 Subject: fs: fat: add rename The implementation roughly follows the POSIX specification for rename() [1]. The ordering of operations attempting to minimize the chance for data loss in unexpected circumstances. The 'mv' command was implemented as a front end for the rename operation as that is what most users are likely familiar with in terms of behavior. The 'FAT_RENAME' Kconfig option was added to prevent code size increase on size-oriented builds like SPL. [1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/rename.html Signed-off-by: Gabriel Dalimonte --- test/py/tests/test_fs/test_rename.py | 372 +++++++++++++++++++++++++++++++++++ 1 file changed, 372 insertions(+) create mode 100644 test/py/tests/test_fs/test_rename.py (limited to 'test/py/tests/test_fs/test_rename.py') diff --git a/test/py/tests/test_fs/test_rename.py b/test/py/tests/test_fs/test_rename.py new file mode 100644 index 00000000000..df2b2fd2945 --- /dev/null +++ b/test/py/tests/test_fs/test_rename.py @@ -0,0 +1,372 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2025 Gabriel Dalimonte +# +# U-Boot File System:rename Test + + +import pytest + +from fstest_defs import * +from fstest_helpers import assert_fs_integrity + +@pytest.mark.boardspec('sandbox') +@pytest.mark.slow +class TestRename(object): + def test_rename1(self, u_boot_console, fs_obj_rename): + """ + Test Case 1 - rename a file (successful mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 1 - rename a file'): + d = 'test1' + src = '%s/file1' % d + dst = '%s/file2' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s' % (ADDR, dst), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('file1' not in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test1'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename2(self, u_boot_console, fs_obj_rename): + """ + Test Case 2 - rename a file to an existing file (successful mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 2 - rename a file to an existing file'): + d = 'test2' + src = '%s/file1' % d + dst = '%s/file_exist' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s' % (ADDR, dst), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('file1' not in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test2'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename3(self, u_boot_console, fs_obj_rename): + """ + Test Case 3 - rename a directory (successful mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 3 - rename a directory'): + d = 'test3' + src = '%s/dir1' % d + dst = '%s/dir2' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s/file1' % (ADDR, dst), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('dir1' not in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test3'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename4(self, u_boot_console, fs_obj_rename): + """ + Test Case 4 - rename a directory to an existing directory (successful + mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 4 - rename a directory to an existing directory'): + d = 'test4' + src = '%s/dir1' % d + dst = '%s/dir2' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s/dir1/file1' % (ADDR, dst), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('dir1' not in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test4'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename5(self, u_boot_console, fs_obj_rename): + """ + Test Case 5 - rename a directory to an existing file (failed mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 5 - rename a directory to an existing file'): + d = 'test5' + src = '%s/dir1' % d + dst = '%s/file2' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('dir1' in ''.join(output)) + assert('file2' in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s' % (ADDR, dst), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test5'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename6(self, u_boot_console, fs_obj_rename): + """ + Test Case 6 - rename a file to an existing empty directory (failed mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 6 - rename a file to an existing empty directory'): + d = 'test6' + src = '%s/existing' % d + dst = '%s/dir2' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s' % (ADDR, src), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('dir2' in ''.join(output)) + assert('existing' in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test6'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename7(self, u_boot_console, fs_obj_rename): + """ + Test Case 7 - rename a directory to a non-empty directory (failed mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 7 - rename a directory to a non-empty directory'): + d = 'test7' + src = '%s/dir1' % d + dst = '%s/dir2' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s/dir1/file1' % (ADDR, dst), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('dir1' in ''.join(output)) + assert('dir2' in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test7'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename8(self, u_boot_console, fs_obj_rename): + """ + Test Case 8 - rename a directory inside itself (failed mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 8 - rename a directory inside itself'): + d = 'test8' + src = '%s/dir1' % d + dst = '%s/dir1/dir1' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s/file1' % (ADDR, src), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('dir1' in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (src), + ]) + assert('file1' in ''.join(output)) + assert('dir1' not in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test8'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename9(self, u_boot_console, fs_obj_rename): + """ + Test Case 9 - rename a directory inside itself with backtracks (failed + mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 9 - rename a directory inside itself with backtracks'): + d = 'test9' + src = '%s/dir1/nested' % d + dst = '%s/dir1/nested/inner/./../../../dir1/nested/inner/another' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, dst), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s/dir1' % (d), + ]) + assert('nested' in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (src), + ]) + assert('inner' in ''.join(output)) + assert('nested' not in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename10(self, u_boot_console, fs_obj_rename): + """ + Test Case 10 - rename a file to itself (successful mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 10 - rename a file to itself'): + d = 'test10' + src = '%s/file1' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, src), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s' % (ADDR, src), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('file1' in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test10'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) + + def test_rename11(self, u_boot_console, fs_obj_rename): + """ + Test Case 11 - rename a directory to itself (successful mv) + """ + fs_type, fs_img, md5val = fs_obj_rename + with u_boot_console.log.section('Test Case 11 - rename a directory to itself'): + # / at the end here is intentional. Ensures trailing / doesn't + # affect mv producing an updated dst path for fs_rename + d = 'test11/' + src = '%sdir1' % d + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % fs_img, + 'setenv filesize', + 'mv host 0:0 %s %s' % (src, d), + ]) + assert('' == ''.join(output)) + + output = u_boot_console.run_command_list([ + 'load host 0:0 %x /%s/file1' % (ADDR, src), + 'printenv filesize']) + assert('filesize=400' in output) + + output = u_boot_console.run_command_list([ + 'ls host 0:0 %s' % (d), + ]) + assert('dir1' in ''.join(output)) + + output = u_boot_console.run_command_list([ + 'md5sum %x $filesize' % ADDR, + 'setenv filesize']) + assert(md5val['test11'] in ''.join(output)) + assert_fs_integrity(fs_type, fs_img) -- cgit v1.2.3 From 752c3769874596d012cd8325099d2ae20123f989 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 9 Feb 2025 09:07:14 -0700 Subject: test/py: Shorten u_boot_console This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary. But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console. It would be too confusing to use con as it would be confused with config and it is probably too short. So shorten it to 'ubman'. Signed-off-by: Simon Glass Link: https://lore.kernel.org/u-boot/CAFLszTgPa4aT_J9h9pqeTtLCVn4x2JvLWRcWRD8NaN3uoSAtyA@mail.gmail.com/ --- test/py/tests/test_fs/test_rename.py | 132 +++++++++++++++++------------------ 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'test/py/tests/test_fs/test_rename.py') diff --git a/test/py/tests/test_fs/test_rename.py b/test/py/tests/test_fs/test_rename.py index df2b2fd2945..e36cff99bb7 100644 --- a/test/py/tests/test_fs/test_rename.py +++ b/test/py/tests/test_fs/test_rename.py @@ -12,360 +12,360 @@ from fstest_helpers import assert_fs_integrity @pytest.mark.boardspec('sandbox') @pytest.mark.slow class TestRename(object): - def test_rename1(self, u_boot_console, fs_obj_rename): + def test_rename1(self, ubman, fs_obj_rename): """ Test Case 1 - rename a file (successful mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 1 - rename a file'): + with ubman.log.section('Test Case 1 - rename a file'): d = 'test1' src = '%s/file1' % d dst = '%s/file2' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s' % (ADDR, dst), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('file1' not in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test1'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename2(self, u_boot_console, fs_obj_rename): + def test_rename2(self, ubman, fs_obj_rename): """ Test Case 2 - rename a file to an existing file (successful mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 2 - rename a file to an existing file'): + with ubman.log.section('Test Case 2 - rename a file to an existing file'): d = 'test2' src = '%s/file1' % d dst = '%s/file_exist' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s' % (ADDR, dst), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('file1' not in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test2'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename3(self, u_boot_console, fs_obj_rename): + def test_rename3(self, ubman, fs_obj_rename): """ Test Case 3 - rename a directory (successful mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 3 - rename a directory'): + with ubman.log.section('Test Case 3 - rename a directory'): d = 'test3' src = '%s/dir1' % d dst = '%s/dir2' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s/file1' % (ADDR, dst), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('dir1' not in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test3'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename4(self, u_boot_console, fs_obj_rename): + def test_rename4(self, ubman, fs_obj_rename): """ Test Case 4 - rename a directory to an existing directory (successful mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 4 - rename a directory to an existing directory'): + with ubman.log.section('Test Case 4 - rename a directory to an existing directory'): d = 'test4' src = '%s/dir1' % d dst = '%s/dir2' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s/dir1/file1' % (ADDR, dst), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('dir1' not in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test4'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename5(self, u_boot_console, fs_obj_rename): + def test_rename5(self, ubman, fs_obj_rename): """ Test Case 5 - rename a directory to an existing file (failed mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 5 - rename a directory to an existing file'): + with ubman.log.section('Test Case 5 - rename a directory to an existing file'): d = 'test5' src = '%s/dir1' % d dst = '%s/file2' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('dir1' in ''.join(output)) assert('file2' in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s' % (ADDR, dst), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test5'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename6(self, u_boot_console, fs_obj_rename): + def test_rename6(self, ubman, fs_obj_rename): """ Test Case 6 - rename a file to an existing empty directory (failed mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 6 - rename a file to an existing empty directory'): + with ubman.log.section('Test Case 6 - rename a file to an existing empty directory'): d = 'test6' src = '%s/existing' % d dst = '%s/dir2' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s' % (ADDR, src), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('dir2' in ''.join(output)) assert('existing' in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test6'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename7(self, u_boot_console, fs_obj_rename): + def test_rename7(self, ubman, fs_obj_rename): """ Test Case 7 - rename a directory to a non-empty directory (failed mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 7 - rename a directory to a non-empty directory'): + with ubman.log.section('Test Case 7 - rename a directory to a non-empty directory'): d = 'test7' src = '%s/dir1' % d dst = '%s/dir2' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s/dir1/file1' % (ADDR, dst), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('dir1' in ''.join(output)) assert('dir2' in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test7'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename8(self, u_boot_console, fs_obj_rename): + def test_rename8(self, ubman, fs_obj_rename): """ Test Case 8 - rename a directory inside itself (failed mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 8 - rename a directory inside itself'): + with ubman.log.section('Test Case 8 - rename a directory inside itself'): d = 'test8' src = '%s/dir1' % d dst = '%s/dir1/dir1' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s/file1' % (ADDR, src), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('dir1' in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (src), ]) assert('file1' in ''.join(output)) assert('dir1' not in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test8'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename9(self, u_boot_console, fs_obj_rename): + def test_rename9(self, ubman, fs_obj_rename): """ Test Case 9 - rename a directory inside itself with backtracks (failed mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 9 - rename a directory inside itself with backtracks'): + with ubman.log.section('Test Case 9 - rename a directory inside itself with backtracks'): d = 'test9' src = '%s/dir1/nested' % d dst = '%s/dir1/nested/inner/./../../../dir1/nested/inner/another' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, dst), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s/dir1' % (d), ]) assert('nested' in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (src), ]) assert('inner' in ''.join(output)) assert('nested' not in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename10(self, u_boot_console, fs_obj_rename): + def test_rename10(self, ubman, fs_obj_rename): """ Test Case 10 - rename a file to itself (successful mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 10 - rename a file to itself'): + with ubman.log.section('Test Case 10 - rename a file to itself'): d = 'test10' src = '%s/file1' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, src), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s' % (ADDR, src), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('file1' in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test10'] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) - def test_rename11(self, u_boot_console, fs_obj_rename): + def test_rename11(self, ubman, fs_obj_rename): """ Test Case 11 - rename a directory to itself (successful mv) """ fs_type, fs_img, md5val = fs_obj_rename - with u_boot_console.log.section('Test Case 11 - rename a directory to itself'): + with ubman.log.section('Test Case 11 - rename a directory to itself'): # / at the end here is intentional. Ensures trailing / doesn't # affect mv producing an updated dst path for fs_rename d = 'test11/' src = '%sdir1' % d - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'mv host 0:0 %s %s' % (src, d), ]) assert('' == ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'load host 0:0 %x /%s/file1' % (ADDR, src), 'printenv filesize']) assert('filesize=400' in output) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'ls host 0:0 %s' % (d), ]) assert('dir1' in ''.join(output)) - output = u_boot_console.run_command_list([ + output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val['test11'] in ''.join(output)) -- cgit v1.2.3