def test_mkdir6(self, u_boot_console, fs_obj_mkdir): """ 'Test Case 6 - create as many directories as amount of directory entries goes beyond a cluster size)' """ fs_type,fs_img = fs_obj_mkdir with u_boot_console.log.section('Test Case 6 - mkdir (create many)'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%smkdir host 0:0 dir6' % fs_type, '%sls host 0:0 /' % fs_type]) assert('dir6/' in ''.join(output)) for i in range(0, 20): output = u_boot_console.run_command( '%smkdir host 0:0 dir6/0123456789abcdef%02x' % (fs_type, i)) output = u_boot_console.run_command('%sls host 0:0 dir6' % fs_type) assert('0123456789abcdef00/' in output) assert('0123456789abcdef13/' in output) output = u_boot_console.run_command( '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_type) assert('./' in output) assert('../' in output) output = u_boot_console.run_command( '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_type) assert('0123456789abcdef00/' in output) assert('0123456789abcdef13/' in output) assert_fs_integrity(fs_type, fs_img)
def test_symlink2(self, u_boot_console, fs_obj_symlink): """ Test Case 2 - create chained links """ fs_type, fs_img, md5val = fs_obj_symlink with u_boot_console.log.section('Test Case 2 - create chained links'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s.link1 ' % (SMALL_FILE, SMALL_FILE), 'ln host 0:0 /%s.link1 /SUBDIR/%s.link2' % (SMALL_FILE, SMALL_FILE), 'ln host 0:0 SUBDIR/%s.link2 /%s.link3' % (SMALL_FILE, SMALL_FILE), ]) assert ('' in ''.join(output)) output = u_boot_console.run_command_list([ '%sload host 0:0 %x /%s.link3' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize' ]) assert ('filesize=100000' in ''.join(output)) # Test Case 4b - Read full 1MB of small file output = u_boot_console.run_command_list( ['md5sum %x $filesize' % ADDR, 'setenv filesize']) assert (md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_mkdir6(self, u_boot_console, fs_obj_mkdir): """ 'Test Case 6 - create as many directories as amount of directory entries goes beyond a cluster size)' """ fs_type, fs_img = fs_obj_mkdir with u_boot_console.log.section('Test Case 6 - mkdir (create many)'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%smkdir host 0:0 dir6' % fs_type, '%sls host 0:0 /' % fs_type ]) assert ('dir6/' in ''.join(output)) for i in range(0, 20): output = u_boot_console.run_command( '%smkdir host 0:0 dir6/0123456789abcdef%02x' % (fs_type, i)) output = u_boot_console.run_command('%sls host 0:0 dir6' % fs_type) assert ('0123456789abcdef00/' in output) assert ('0123456789abcdef13/' in output) output = u_boot_console.run_command( '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_type) assert ('./' in output) assert ('../' in output) output = u_boot_console.run_command( '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_type) assert ('0123456789abcdef00/' in output) assert ('0123456789abcdef13/' in output) assert_fs_integrity(fs_type, fs_img)
def test_fs13(self, u_boot_console, fs_obj_basic): """ Test Case 13 - write to a file with "/./<filename>" """ fs_type,fs_img,md5val = fs_obj_basic with u_boot_console.log.section('Test Case 13 - write ("./<file>")'): # Read 1MB from small file # Write it via "same directory", i.e. "." dirent # Test Case 13a - Check directory traversal output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), '%swrite host 0:0 %x /./%s2 $filesize' % (fs_type, ADDR, SMALL_FILE)]) assert('1048576 bytes written' in ''.join(output)) # Test Case 13b - Check md5 of written to is same # as the one read from output = u_boot_console.run_command_list([ 'mw.b %x 00 100' % ADDR, '%sload host 0:0 %x /./%s2' % (fs_type, ADDR, SMALL_FILE), 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[0] in ''.join(output)) # Test Case 13c - Check md5 of written to is same # as the one read from output = u_boot_console.run_command_list([ 'mw.b %x 00 100' % ADDR, '%sload host 0:0 %x /%s2' % (fs_type, ADDR, SMALL_FILE), 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext7(self, u_boot_console, fs_obj_ext): """ Test Case 7 - write at the end (append) """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 7 - write at the end (append)'): # Test Case 7a - Check if command successfully returned output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), '%swrite host 0:0 %x /dir1/%s.w7 $filesize' % (fs_type, ADDR, MIN_FILE)]) output = u_boot_console.run_command( '%swrite host 0:0 %x /dir1/%s.w7 $filesize $filesize' % (fs_type, ADDR, MIN_FILE)) assert('20480 bytes written' in output) # Test Case 7b - Check size of written file output = u_boot_console.run_command_list([ '%ssize host 0:0 /dir1/%s.w7' % (fs_type, MIN_FILE), 'printenv filesize', 'setenv filesize']) assert('filesize=a000' in ''.join(output)) # Test Case 7c - Check md5 of file content output = u_boot_console.run_command_list([ 'mw.b %x 00 100' % ADDR, '%sload host 0:0 %x /dir1/%s.w7' % (fs_type, ADDR, MIN_FILE), 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[3] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext4(self, u_boot_console, fs_obj_ext): """ Test Case 4 - write at non-zero offset, enlarging file size """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 4 - write at non-zero offset, enlarging file size'): # Test Case 4a - Check if command successfully returned output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), '%swrite host 0:0 %x /dir1/%s.w4 $filesize' % (fs_type, ADDR, MIN_FILE)]) output = u_boot_console.run_command( '%swrite host 0:0 %x /dir1/%s.w4 $filesize 0x1400' % (fs_type, ADDR, MIN_FILE)) assert('20480 bytes written' in output) # Test Case 4b - Check size of written file output = u_boot_console.run_command_list([ '%ssize host 0:0 /dir1/%s.w4' % (fs_type, MIN_FILE), 'printenv filesize', 'setenv filesize']) assert('filesize=6400' in ''.join(output)) # Test Case 4c - Check md5 of file content output = u_boot_console.run_command_list([ 'mw.b %x 00 100' % ADDR, '%sload host 0:0 %x /dir1/%s.w4' % (fs_type, ADDR, MIN_FILE), 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[1] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_symlink3(self, u_boot_console, fs_obj_symlink): """ Test Case 3 - replace file/link with link """ fs_type, fs_img, md5val = fs_obj_symlink with u_boot_console.log.section('Test Case 1 - create link and read'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s ' % (MEDIUM_FILE, SMALL_FILE), 'ln host 0:0 %s /%s.link ' % (MEDIUM_FILE, MEDIUM_FILE), ]) assert('' in ''.join(output)) output = u_boot_console.run_command_list([ '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize']) assert('filesize=a00000' in ''.join(output)) output = u_boot_console.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[1] in ''.join(output)) output = u_boot_console.run_command_list([ 'ln host 0:0 %s.link /%s ' % (MEDIUM_FILE, SMALL_FILE), '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize']) assert('filesize=a00000' in ''.join(output)) output = u_boot_console.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[1] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_symlink2(self, u_boot_console, fs_obj_symlink): """ Test Case 2 - create chained links """ fs_type, fs_img, md5val = fs_obj_symlink with u_boot_console.log.section('Test Case 2 - create chained links'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s.link1 ' % (SMALL_FILE, SMALL_FILE), 'ln host 0:0 /%s.link1 /SUBDIR/%s.link2' % ( SMALL_FILE, SMALL_FILE), 'ln host 0:0 SUBDIR/%s.link2 /%s.link3' % ( SMALL_FILE, SMALL_FILE), ]) assert('' in ''.join(output)) output = u_boot_console.run_command_list([ '%sload host 0:0 %x /%s.link3' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize']) assert('filesize=100000' in ''.join(output)) # Test Case 4b - Read full 1MB of small file output = u_boot_console.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_symlink3(self, u_boot_console, fs_obj_symlink): """ Test Case 3 - replace file/link with link """ fs_type, fs_img, md5val = fs_obj_symlink with u_boot_console.log.section('Test Case 1 - create link and read'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s ' % (MEDIUM_FILE, SMALL_FILE), 'ln host 0:0 %s /%s.link ' % (MEDIUM_FILE, MEDIUM_FILE), ]) assert ('' in ''.join(output)) output = u_boot_console.run_command_list([ '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize' ]) assert ('filesize=a00000' in ''.join(output)) output = u_boot_console.run_command_list( ['md5sum %x $filesize' % ADDR, 'setenv filesize']) assert (md5val[1] in ''.join(output)) output = u_boot_console.run_command_list([ 'ln host 0:0 %s.link /%s ' % (MEDIUM_FILE, SMALL_FILE), '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize' ]) assert ('filesize=a00000' in ''.join(output)) output = u_boot_console.run_command_list( ['md5sum %x $filesize' % ADDR, 'setenv filesize']) assert (md5val[1] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext6(self, u_boot_console, fs_obj_ext): """ Test Case 6 - write nothing at the start, truncating to zero """ fs_type, fs_img, md5val = fs_obj_ext with u_boot_console.log.section( 'Test Case 6 - write nothing at the start, truncating to zero' ): # Test Case 6a - Check if command successfully returned output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), '%swrite host 0:0 %x /dir1/%s.w6 $filesize' % (fs_type, ADDR, MIN_FILE) ]) output = u_boot_console.run_command( '%swrite host 0:0 %x /dir1/%s.w6 0 0' % (fs_type, ADDR, MIN_FILE)) assert ('0 bytes written' in output) # Test Case 6b - Check size of written file output = u_boot_console.run_command_list([ '%ssize host 0:0 /dir1/%s.w6' % (fs_type, MIN_FILE), 'printenv filesize', 'setenv filesize' ]) assert ('filesize=0' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_mkdir5(self, u_boot_console, fs_obj_mkdir): """ Test Case 5 - trying to create ".." should fail """ fs_type, fs_img = fs_obj_mkdir with u_boot_console.log.section('Test Case 5 - mkdir ("..")'): output = u_boot_console.run_command_list( ['host bind 0 %s' % fs_img, '%smkdir host 0:0 ..' % fs_type]) assert ('Unable to create a directory' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_unlink6(self, u_boot_console, fs_obj_unlink): """ Test Case 6 - trying to deleting a "." should fail """ fs_type, fs_img = fs_obj_unlink with u_boot_console.log.section('Test Case 6 - unlink (".")'): output = u_boot_console.run_command_list( ['host bind 0 %s' % fs_img, '%srm host 0:0 dir5/.' % fs_type]) assert ('directory is not empty' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_mkdir5(self, u_boot_console, fs_obj_mkdir): """ Test Case 5 - trying to create ".." should fail """ fs_type,fs_img = fs_obj_mkdir with u_boot_console.log.section('Test Case 5 - mkdir ("..")'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%smkdir host 0:0 ..' % fs_type]) assert('Unable to create a directory' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_unlink3(self, u_boot_console, fs_obj_unlink): """ Test Case 3 - trying to delete a non-existing file should fail """ fs_type, fs_img = fs_obj_unlink with u_boot_console.log.section('Test Case 3 - unlink (non-existing)'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%srm host 0:0 dir1/nofile' % fs_type ]) assert ('nofile: doesn\'t exist' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_mkdir3(self, u_boot_console, fs_obj_mkdir): """ Test Case 3 - trying to create a directory with a non-existing path should fail """ fs_type,fs_img = fs_obj_mkdir with u_boot_console.log.section('Test Case 3 - mkdir (non-existing path)'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%smkdir host 0:0 none/dir3' % fs_type]) assert('Unable to create a directory' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext9(self, u_boot_console, fs_obj_ext): """ Test Case 9 - write to a non-existing file at non-zero offset """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 9 - write to non-existing file with non-zero offset'): # Test Case 9a - Check if command expectedly failed output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), '%swrite host 0:0 %x /dir1/%s.w9 0x1400 0x1400' % (fs_type, ADDR, MIN_FILE)]) assert('Unable to write "/dir1' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext3(self, u_boot_console, fs_obj_ext): """ Test Case 3 - write to a file with invalid path """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 3 - write with invalid path'): # Test Case 3 - Check if command expectedly failed output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), '%swrite host 0:0 %x /dir1/none/%s.w3 $filesize' % (fs_type, ADDR, MIN_FILE)]) assert('Unable to write "/dir1/none/' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_unlink4(self, u_boot_console, fs_obj_unlink): """ Test Case 4 - delete an empty directory """ fs_type, fs_img = fs_obj_unlink with u_boot_console.log.section('Test Case 4 - unlink (directory)'): output = u_boot_console.run_command_list( ['host bind 0 %s' % fs_img, '%srm host 0:0 dir4' % fs_type]) assert ('' == ''.join(output)) output = u_boot_console.run_command('%sls host 0:0 /' % fs_type) assert (not 'dir4' in output) assert_fs_integrity(fs_type, fs_img)
def test_mkdir3(self, u_boot_console, fs_obj_mkdir): """ Test Case 3 - trying to create a directory with a non-existing path should fail """ fs_type, fs_img = fs_obj_mkdir with u_boot_console.log.section( 'Test Case 3 - mkdir (non-existing path)'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%smkdir host 0:0 none/dir3' % fs_type ]) assert ('Unable to create a directory' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs12(self, u_boot_console, fs_obj_basic): """ Test Case 12 - write to "." directory """ fs_type,fs_img,md5val = fs_obj_basic with u_boot_console.log.section('Test Case 12 - write (".")'): # Next test case checks writing a file whose dirent # is the first in the block, which is always true for "." # The write should fail, but the lookup should work # Test Case 12 - Check directory traversal output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%swrite host 0:0 %x /. 0x10' % (fs_type, ADDR)]) assert('Unable to write' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_mkdir2(self, u_boot_console, fs_obj_mkdir): """ Test Case 2 - create a directory under a sub-directory """ fs_type,fs_img = fs_obj_mkdir with u_boot_console.log.section('Test Case 2 - mkdir (sub-sub directory)'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%smkdir host 0:0 dir1/dir2' % fs_type, '%sls host 0:0 dir1' % fs_type]) assert('dir2/' in ''.join(output)) output = u_boot_console.run_command( '%sls host 0:0 dir1/dir2' % fs_type) assert('./' in output) assert('../' in output) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext8(self, u_boot_console, fs_obj_ext): """ Test Case 8 - write at offset beyond the end of file """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 8 - write beyond the end'): # Test Case 8a - Check if command expectedly failed output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), '%swrite host 0:0 %x /dir1/%s.w8 $filesize' % (fs_type, ADDR, MIN_FILE)]) output = u_boot_console.run_command( '%swrite host 0:0 %x /dir1/%s.w8 0x1400 %x' % (fs_type, ADDR, MIN_FILE, 0x100000 + 0x1400)) assert('Unable to write "/dir1' in output) assert_fs_integrity(fs_type, fs_img)
def test_mkdir1(self, u_boot_console, fs_obj_mkdir): """ Test Case 1 - create a directory under a root """ fs_type, fs_img = fs_obj_mkdir with u_boot_console.log.section('Test Case 1 - mkdir'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%smkdir host 0:0 dir1' % fs_type, '%sls host 0:0 /' % fs_type ]) assert ('dir1/' in ''.join(output)) output = u_boot_console.run_command('%sls host 0:0 dir1' % fs_type) assert ('./' in output) assert ('../' in output) assert_fs_integrity(fs_type, fs_img)
def test_unlink2(self, u_boot_console, fs_obj_unlink): """ Test Case 2 - delete many files """ fs_type, fs_img = fs_obj_unlink with u_boot_console.log.section('Test Case 2 - unlink (many)'): output = u_boot_console.run_command('host bind 0 %s' % fs_img) for i in range(0, 20): output = u_boot_console.run_command_list([ '%srm host 0:0 dir2/0123456789abcdef%02x' % (fs_type, i), '%sls host 0:0 dir2/0123456789abcdef%02x' % (fs_type, i) ]) assert ('' == ''.join(output)) output = u_boot_console.run_command('%sls host 0:0 dir2' % fs_type) assert ('0 file(s), 2 dir(s)' in output) assert_fs_integrity(fs_type, fs_img)
def test_unlink1(self, u_boot_console, fs_obj_unlink): """ Test Case 1 - delete a file """ fs_type, fs_img = fs_obj_unlink with u_boot_console.log.section('Test Case 1 - unlink (file)'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%srm host 0:0 dir1/file1' % fs_type, '%sls host 0:0 dir1/file1' % fs_type ]) assert ('' == ''.join(output)) output = u_boot_console.run_command('%sls host 0:0 dir1/' % fs_type) assert (not 'file1' in output) assert ('file2' in output) assert_fs_integrity(fs_type, fs_img)
def test_symlink4(self, u_boot_console, fs_obj_symlink): """ Test Case 4 - create a broken link """ fs_type, fs_img, md5val = fs_obj_symlink with u_boot_console.log.section('Test Case 1 - create link and read'): output = u_boot_console.run_command_list([ 'setenv filesize', 'ln host 0:0 nowhere /link ', ]) assert ('' in ''.join(output)) output = u_boot_console.run_command('%sload host 0:0 %x /link' % (fs_type, ADDR)) with u_boot_console.disable_check('error_notification'): output = u_boot_console.run_command('printenv filesize') assert ('"filesize" not defined' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext11(self, u_boot_console, fs_obj_ext): """ 'Test Case 11 - create/delete as many directories under non-root directory as amount of directory entries goes beyond one cluster size)' """ fs_type, fs_img, md5val = fs_obj_ext with u_boot_console.log.section('Test Case 11 - create/delete (many)'): # Test Case 11a - Create many files # Please note that the size of directory entry is 32 bytes. # So one typical cluster may holds 64 (2048/32) entries. output = u_boot_console.run_command('host bind 0 %s' % fs_img) for i in range(0, 66): output = u_boot_console.run_command( '%swrite host 0:0 %x /dir1/FILE0123456789_%02x 100' % (fs_type, ADDR, i)) output = u_boot_console.run_command('%sls host 0:0 /dir1' % fs_type) assert ('FILE0123456789_00' in output) assert ('FILE0123456789_41' in output) # Test Case 11b - Delete many files for i in range(0, 66): output = u_boot_console.run_command( '%srm host 0:0 /dir1/FILE0123456789_%02x' % (fs_type, i)) output = u_boot_console.run_command('%sls host 0:0 /dir1' % fs_type) assert (not 'FILE0123456789_00' in output) assert (not 'FILE0123456789_41' in output) # Test Case 11c - Create many files again # Please note no.64 and 65 are intentionally re-created for i in range(64, 128): output = u_boot_console.run_command( '%swrite host 0:0 %x /dir1/FILE0123456789_%02x 100' % (fs_type, ADDR, i)) output = u_boot_console.run_command('%sls host 0:0 /dir1' % fs_type) assert ('FILE0123456789_40' in output) assert ('FILE0123456789_79' in output) assert_fs_integrity(fs_type, fs_img)
def test_symlink4(self, u_boot_console, fs_obj_symlink): """ Test Case 4 - create a broken link """ fs_type, fs_img, md5val = fs_obj_symlink with u_boot_console.log.section('Test Case 1 - create link and read'): output = u_boot_console.run_command_list([ 'setenv filesize', 'ln host 0:0 nowhere /link ', ]) assert('' in ''.join(output)) output = u_boot_console.run_command( '%sload host 0:0 %x /link' % (fs_type, ADDR)) with u_boot_console.disable_check('error_notification'): output = u_boot_console.run_command('printenv filesize') assert('"filesize" not defined' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext2(self, u_boot_console, fs_obj_ext): """ Test Case 2 - write to a file with relative path """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 2 - write with rel path'): # Test Case 2a - Check if command successfully returned output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), '%swrite host 0:0 %x dir1/%s.w2 $filesize' % (fs_type, ADDR, MIN_FILE)]) assert('20480 bytes written' in ''.join(output)) # Test Case 2b - Check md5 of file content output = u_boot_console.run_command_list([ 'mw.b %x 00 100' % ADDR, '%sload host 0:0 %x dir1/%s.w2' % (fs_type, ADDR, MIN_FILE), 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_symlink1(self, u_boot_console, fs_obj_symlink): """ Test Case 1 - create a link. and follow it when reading """ fs_type, fs_img, md5val = fs_obj_symlink with u_boot_console.log.section('Test Case 1 - create link and read'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s.link ' % (SMALL_FILE, SMALL_FILE), ]) assert ('' in ''.join(output)) output = u_boot_console.run_command_list([ '%sload host 0:0 %x /%s.link' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize' ]) assert ('filesize=100000' in ''.join(output)) # Test Case 4b - Read full 1MB of small file output = u_boot_console.run_command_list( ['md5sum %x $filesize' % ADDR, 'setenv filesize']) assert (md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_symlink1(self, u_boot_console, fs_obj_symlink): """ Test Case 1 - create a link. and follow it when reading """ fs_type, fs_img, md5val = fs_obj_symlink with u_boot_console.log.section('Test Case 1 - create link and read'): output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s.link ' % (SMALL_FILE, SMALL_FILE), ]) assert('' in ''.join(output)) output = u_boot_console.run_command_list([ '%sload host 0:0 %x /%s.link' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize']) assert('filesize=100000' in ''.join(output)) # Test Case 4b - Read full 1MB of small file output = u_boot_console.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs11(self, u_boot_console, fs_obj_basic): """ Test Case 11 - write' """ fs_type,fs_img,md5val = fs_obj_basic with u_boot_console.log.section('Test Case 11 - write'): # Read 1MB from small file # Write it back to test the writes # Test Case 11a - Check that the write succeeded output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), '%swrite host 0:0 %x /%s.w $filesize' % (fs_type, ADDR, SMALL_FILE)]) assert('1048576 bytes written' in ''.join(output)) # Test Case 11b - Check md5 of written to is same # as the one read from output = u_boot_console.run_command_list([ '%sload host 0:0 %x /%s.w' % (fs_type, ADDR, SMALL_FILE), 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img)
def test_fs_ext6(self, u_boot_console, fs_obj_ext): """ Test Case 6 - write nothing at the start, truncating to zero """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 6 - write nothing at the start, truncating to zero'): # Test Case 6a - Check if command successfully returned output = u_boot_console.run_command_list([ 'host bind 0 %s' % fs_img, '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), '%swrite host 0:0 %x /dir1/%s.w6 $filesize' % (fs_type, ADDR, MIN_FILE)]) output = u_boot_console.run_command( '%swrite host 0:0 %x /dir1/%s.w6 0 0' % (fs_type, ADDR, MIN_FILE)) assert('0 bytes written' in output) # Test Case 6b - Check size of written file output = u_boot_console.run_command_list([ '%ssize host 0:0 /dir1/%s.w6' % (fs_type, MIN_FILE), 'printenv filesize', 'setenv filesize']) assert('filesize=0' in ''.join(output)) assert_fs_integrity(fs_type, fs_img)