diff options
Diffstat (limited to 'test/py/tests/test_fs/test_erofs.py')
-rw-r--r-- | test/py/tests/test_fs/test_erofs.py | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/test/py/tests/test_fs/test_erofs.py b/test/py/tests/test_fs/test_erofs.py index 87ad8f2d5fd..a2bb6b505f2 100644 --- a/test/py/tests/test_fs/test_erofs.py +++ b/test/py/tests/test_fs/test_erofs.py @@ -65,64 +65,64 @@ def clean_erofs_image(build_dir): image_path = os.path.join(build_dir, EROFS_IMAGE_NAME) os.remove(image_path) -def erofs_ls_at_root(u_boot_console): +def erofs_ls_at_root(ubman): """ Test if all the present files and directories were listed. """ - no_slash = u_boot_console.run_command('erofsls host 0') - slash = u_boot_console.run_command('erofsls host 0 /') + no_slash = ubman.run_command('erofsls host 0') + slash = ubman.run_command('erofsls host 0 /') assert no_slash == slash expected_lines = ['./', '../', '4096 f4096', '7812 f7812', 'subdir/', '<SYM> symdir', '<SYM> symfile', '4 file(s), 3 dir(s)'] - output = u_boot_console.run_command('erofsls host 0') + output = ubman.run_command('erofsls host 0') for line in expected_lines: assert line in output -def erofs_ls_at_subdir(u_boot_console): +def erofs_ls_at_subdir(ubman): """ Test if the path resolution works. """ expected_lines = ['./', '../', '100 subdir-file', '1 file(s), 2 dir(s)'] - output = u_boot_console.run_command('erofsls host 0 subdir') + output = ubman.run_command('erofsls host 0 subdir') for line in expected_lines: assert line in output -def erofs_ls_at_symlink(u_boot_console): +def erofs_ls_at_symlink(ubman): """ Test if the symbolic link's target resolution works. """ - output = u_boot_console.run_command('erofsls host 0 symdir') - output_subdir = u_boot_console.run_command('erofsls host 0 subdir') + output = ubman.run_command('erofsls host 0 symdir') + output_subdir = ubman.run_command('erofsls host 0 subdir') assert output == output_subdir expected_lines = ['./', '../', '100 subdir-file', '1 file(s), 2 dir(s)'] for line in expected_lines: assert line in output -def erofs_ls_at_non_existent_dir(u_boot_console): +def erofs_ls_at_non_existent_dir(ubman): """ Test if the EROFS support will crash when get a nonexistent directory. """ - out_non_existent = u_boot_console.run_command('erofsls host 0 fff') - out_not_dir = u_boot_console.run_command('erofsls host 0 f1000') + out_non_existent = ubman.run_command('erofsls host 0 fff') + out_not_dir = ubman.run_command('erofsls host 0 f1000') assert out_non_existent == out_not_dir assert '' in out_non_existent -def erofs_load_files(u_boot_console, files, sizes, address): +def erofs_load_files(ubman, files, sizes, address): """ Loads files and asserts their checksums. """ - build_dir = u_boot_console.config.build_dir + build_dir = ubman.config.build_dir for (file, size) in zip(files, sizes): - out = u_boot_console.run_command('erofsload host 0 {} {}'.format(address, file)) + out = ubman.run_command('erofsload host 0 {} {}'.format(address, file)) # check if the right amount of bytes was read assert size in out # calculate u-boot file's checksum - out = u_boot_console.run_command('md5sum {} {}'.format(address, hex(int(size)))) + out = ubman.run_command('md5sum {} {}'.format(address, hex(int(size)))) u_boot_checksum = out.split()[-1] # calculate original file's checksum @@ -134,54 +134,54 @@ def erofs_load_files(u_boot_console, files, sizes, address): # compare checksum assert u_boot_checksum == original_checksum -def erofs_load_files_at_root(u_boot_console): +def erofs_load_files_at_root(ubman): """ Test load file from the root directory. """ files = ['f4096', 'f7812'] sizes = ['4096', '7812'] address = '$kernel_addr_r' - erofs_load_files(u_boot_console, files, sizes, address) + erofs_load_files(ubman, files, sizes, address) -def erofs_load_files_at_subdir(u_boot_console): +def erofs_load_files_at_subdir(ubman): """ Test load file from the subdirectory. """ files = ['subdir/subdir-file'] sizes = ['100'] address = '$kernel_addr_r' - erofs_load_files(u_boot_console, files, sizes, address) + erofs_load_files(ubman, files, sizes, address) -def erofs_load_files_at_symlink(u_boot_console): +def erofs_load_files_at_symlink(ubman): """ Test load file from the symlink. """ files = ['symfile'] sizes = ['7812'] address = '$kernel_addr_r' - erofs_load_files(u_boot_console, files, sizes, address) + erofs_load_files(ubman, files, sizes, address) -def erofs_load_non_existent_file(u_boot_console): +def erofs_load_non_existent_file(ubman): """ Test if the EROFS support will crash when load a nonexistent file. """ address = '$kernel_addr_r' file = 'non-existent' - out = u_boot_console.run_command('erofsload host 0 {} {}'.format(address, file)) + out = ubman.run_command('erofsload host 0 {} {}'.format(address, file)) assert 'Failed to load' in out -def erofs_run_all_tests(u_boot_console): +def erofs_run_all_tests(ubman): """ Runs all test cases. """ - erofs_ls_at_root(u_boot_console) - erofs_ls_at_subdir(u_boot_console) - erofs_ls_at_symlink(u_boot_console) - erofs_ls_at_non_existent_dir(u_boot_console) - erofs_load_files_at_root(u_boot_console) - erofs_load_files_at_subdir(u_boot_console) - erofs_load_files_at_symlink(u_boot_console) - erofs_load_non_existent_file(u_boot_console) + erofs_ls_at_root(ubman) + erofs_ls_at_subdir(ubman) + erofs_ls_at_symlink(ubman) + erofs_ls_at_non_existent_dir(ubman) + erofs_load_files_at_root(ubman) + erofs_load_files_at_subdir(ubman) + erofs_load_files_at_symlink(ubman) + erofs_load_non_existent_file(ubman) @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_fs_generic') @@ -190,11 +190,11 @@ def erofs_run_all_tests(u_boot_console): @pytest.mark.requiredtool('mkfs.erofs') @pytest.mark.requiredtool('md5sum') -def test_erofs(u_boot_console): +def test_erofs(ubman): """ Executes the erofs test suite. """ - build_dir = u_boot_console.config.build_dir + build_dir = ubman.config.build_dir # If the EFI subsystem is enabled and initialized, EFI subsystem tries to # add EFI boot option when the new disk is detected. If there is no EFI @@ -203,15 +203,15 @@ def test_erofs(u_boot_console): # Restart U-Boot to clear the previous state. # TODO: Ideally EFI test cases need to be fixed, but it will # increase the number of system reset. - u_boot_console.restart_uboot() + ubman.restart_uboot() try: # setup test environment make_erofs_image(build_dir) image_path = os.path.join(build_dir, EROFS_IMAGE_NAME) - u_boot_console.run_command('host bind 0 {}'.format(image_path)) + ubman.run_command('host bind 0 {}'.format(image_path)) # run all tests - erofs_run_all_tests(u_boot_console) + erofs_run_all_tests(ubman) except: clean_erofs_image(build_dir) raise AssertionError |