"Das U-Boot" Source Tree

test_fs: Allow testing FS_GENERIC

The generic filesystem interface was so far untested. The interface
is similar to the FS specific interfaces with FS specific prefixes,
like ext4ls, fatmkdir, ... but it does not have any prefixes, i.e.
it provides plain ls, mkdir, ... commands.

Extend the test parameters to include 'fs_cmd_prefix' and optionally
'fs_cmd_write' parameters. The 'fs_cmd_prefix' allow specifying the
filesystem specific command prefix, like 'ext4' in 'ext4ls'. The
'fs_cmd_write' allows selecting between 'write'/'save' command name
for storing files into the filesystem, see last paragraph.

Introduce new 'fs_generic' fs_type which is used to parametrize existing
tests and run them without any prefixes if detected, thus testing the
generic filesystem interface. Use the fatfs as the backing store for the
generic FS tests.

The check_ubconfig needs to be slightly adjusted to avoid test for
CMD_FS_GENERIC_WRITE which does not exist separately from CMD_FS_GENERIC.

The CMD_FS_GENERIC does not provide generic 'write' command, instead
the generic equivalent command is called 'save' . Add simple ternary
oeprator to use 'save' command for CMD_FS_GENERIC tests and '..write'
commands for filesystem specific tests.

Enable generic filesystem tests for basic/extended/mkdir/unlink tests.

Signed-off-by: Marek Vasut <marex@denx.de>

authored by

Marek Vasut and committed by
Tom Rini
6592425c fa4c9826

+187 -162
+1 -1
test/py/tests/fs_helper.py
··· 35 35 else: 36 36 mkfs_opt = '' 37 37 38 - if re.match('fat', fs_type): 38 + if re.match('fat', fs_type) or fs_type == 'fs_generic': 39 39 fs_lnxtype = 'vfat' 40 40 else: 41 41 fs_lnxtype = fs_type
+32 -8
test/py/tests/test_fs/conftest.py
··· 11 11 # pylint: disable=E0611 12 12 from tests import fs_helper 13 13 14 - supported_fs_basic = ['fat16', 'fat32', 'ext4'] 15 - supported_fs_ext = ['fat12', 'fat16', 'fat32'] 14 + supported_fs_basic = ['fat16', 'fat32', 'ext4', 'fs_generic'] 15 + supported_fs_ext = ['fat12', 'fat16', 'fat32', 'fs_generic'] 16 16 supported_fs_fat = ['fat12', 'fat16'] 17 - supported_fs_mkdir = ['fat12', 'fat16', 'fat32'] 18 - supported_fs_unlink = ['fat12', 'fat16', 'fat32'] 17 + supported_fs_mkdir = ['fat12', 'fat16', 'fat32', 'fs_generic'] 18 + supported_fs_unlink = ['fat12', 'fat16', 'fat32', 'fs_generic'] 19 19 supported_fs_symlink = ['ext4'] 20 20 supported_fs_rename = ['fat12', 'fat16', 'fat32'] 21 21 ··· 108 108 # 109 109 # Helper functions 110 110 # 111 + def fstype_to_prefix(fs_type): 112 + """Convert a file system type to an U-Boot command prefix 113 + 114 + Args: 115 + fs_type: File system type. 116 + 117 + Return: 118 + A corresponding command prefix for file system type. 119 + """ 120 + if fs_type == 'fs_generic': 121 + return '' 122 + elif re.match('fat', fs_type): 123 + return 'fat' 124 + else: 125 + return fs_type 126 + 111 127 def fstype_to_ubname(fs_type): 112 128 """Convert a file system type to an U-Boot specific string 113 129 ··· 141 157 """ 142 158 if not config.buildconfig.get('config_cmd_%s' % fs_type, None): 143 159 pytest.skip('.config feature "CMD_%s" not enabled' % fs_type.upper()) 160 + if fs_type == 'fs_generic': 161 + return 144 162 if not config.buildconfig.get('config_%s_write' % fs_type, None): 145 163 pytest.skip('.config feature "%s_WRITE" not enabled' 146 164 % fs_type.upper()) ··· 178 196 volume file name and a list of MD5 hashes. 179 197 """ 180 198 fs_type = request.param 199 + fs_cmd_prefix = fstype_to_prefix(fs_type) 200 + fs_cmd_write = 'save' if fs_type == 'fs_generic' else 'write' 181 201 fs_img = '' 182 202 183 203 fs_ubtype = fstype_to_ubname(fs_type) ··· 267 287 pytest.skip('Setup failed for filesystem: ' + fs_type + '. {}'.format(err)) 268 288 return 269 289 else: 270 - yield [fs_ubtype, fs_img, md5val] 290 + yield [fs_ubtype, fs_cmd_prefix, fs_cmd_write, fs_img, md5val] 271 291 finally: 272 292 call('rm -rf %s' % scratch_dir, shell=True) 273 293 call('rm -f %s' % fs_img, shell=True) ··· 288 308 volume file name and a list of MD5 hashes. 289 309 """ 290 310 fs_type = request.param 311 + fs_cmd_prefix = fstype_to_prefix(fs_type) 312 + fs_cmd_write = 'save' if fs_type == 'fs_generic' else 'write' 291 313 fs_img = '' 292 314 293 315 fs_ubtype = fstype_to_ubname(fs_type) ··· 357 379 pytest.skip('Setup failed for filesystem: ' + fs_type) 358 380 return 359 381 else: 360 - yield [fs_ubtype, fs_img, md5val] 382 + yield [fs_ubtype, fs_cmd_prefix, fs_cmd_write, fs_img, md5val] 361 383 finally: 362 384 call('rm -rf %s' % scratch_dir, shell=True) 363 385 call('rm -f %s' % fs_img, shell=True) ··· 378 400 volume file name. 379 401 """ 380 402 fs_type = request.param 403 + fs_cmd_prefix = fstype_to_prefix(fs_type) 381 404 fs_img = '' 382 405 383 406 fs_ubtype = fstype_to_ubname(fs_type) ··· 390 413 pytest.skip('Setup failed for filesystem: ' + fs_type) 391 414 return 392 415 else: 393 - yield [fs_ubtype, fs_img] 416 + yield [fs_ubtype, fs_cmd_prefix, fs_img] 394 417 call('rm -f %s' % fs_img, shell=True) 395 418 396 419 # ··· 409 432 volume file name. 410 433 """ 411 434 fs_type = request.param 435 + fs_cmd_prefix = fstype_to_prefix(fs_type) 412 436 fs_img = '' 413 437 414 438 fs_ubtype = fstype_to_ubname(fs_type) ··· 456 480 pytest.skip('Setup failed for filesystem: ' + fs_type) 457 481 return 458 482 else: 459 - yield [fs_ubtype, fs_img] 483 + yield [fs_ubtype, fs_cmd_prefix, fs_img] 460 484 finally: 461 485 call('rm -rf %s' % scratch_dir, shell=True) 462 486 call('rm -f %s' % fs_img, shell=True)
+36 -35
test/py/tests/test_fs/test_basic.py
··· 20 20 """ 21 21 Test Case 1 - ls command, listing a root directory and invalid directory 22 22 """ 23 - fs_type,fs_img,md5val = fs_obj_basic 23 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 24 24 with ubman.log.section('Test Case 1a - ls'): 25 25 # Test Case 1 - ls 26 26 output = ubman.run_command_list([ 27 27 'host bind 0 %s' % fs_img, 28 - '%sls host 0:0' % fs_type]) 28 + '%sls host 0:0' % fs_cmd_prefix]) 29 29 assert(re.search('2621440000 *%s' % BIG_FILE, ''.join(output))) 30 30 assert(re.search('1048576 *%s' % SMALL_FILE, ''.join(output))) 31 31 32 32 with ubman.log.section('Test Case 1b - ls (invalid dir)'): 33 33 # In addition, test with a nonexistent directory to see if we crash. 34 34 output = ubman.run_command( 35 - '%sls host 0:0 invalid_d' % fs_type) 35 + '%sls host 0:0 invalid_d' % fs_cmd_prefix) 36 36 assert('' == output) 37 37 38 38 def test_fs2(self, ubman, fs_obj_basic): 39 39 """ 40 40 Test Case 2 - size command for a small file 41 41 """ 42 - fs_type,fs_img,md5val = fs_obj_basic 42 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 43 43 with ubman.log.section('Test Case 2a - size (small)'): 44 44 # 1MB is 0x0010 0000 45 45 # Test Case 2a - size of small file 46 46 output = ubman.run_command_list([ 47 47 'host bind 0 %s' % fs_img, 48 - '%ssize host 0:0 /%s' % (fs_type, SMALL_FILE), 48 + '%ssize host 0:0 /%s' % (fs_cmd_prefix, SMALL_FILE), 49 49 'printenv filesize', 50 50 'setenv filesize']) 51 51 assert('filesize=100000' in ''.join(output)) ··· 53 53 with ubman.log.section('Test Case 2b - size (/../<file>)'): 54 54 # Test Case 2b - size of small file via a path using '..' 55 55 output = ubman.run_command_list([ 56 - '%ssize host 0:0 /SUBDIR/../%s' % (fs_type, SMALL_FILE), 56 + '%ssize host 0:0 /SUBDIR/../%s' % (fs_cmd_prefix, SMALL_FILE), 57 57 'printenv filesize', 58 58 'setenv filesize']) 59 59 assert('filesize=100000' in ''.join(output)) ··· 62 62 """ 63 63 Test Case 3 - size command for a large file 64 64 """ 65 - fs_type,fs_img,md5val = fs_obj_basic 65 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 66 66 with ubman.log.section('Test Case 3 - size (large)'): 67 67 # 2.5GB (1024*1024*2500) is 0x9C40 0000 68 68 # Test Case 3 - size of big file 69 69 output = ubman.run_command_list([ 70 70 'host bind 0 %s' % fs_img, 71 - '%ssize host 0:0 /%s' % (fs_type, BIG_FILE), 71 + '%ssize host 0:0 /%s' % (fs_cmd_prefix, BIG_FILE), 72 72 'printenv filesize', 73 73 'setenv filesize']) 74 74 assert('filesize=9c400000' in ''.join(output)) ··· 77 77 """ 78 78 Test Case 4 - load a small file, 1MB 79 79 """ 80 - fs_type,fs_img,md5val = fs_obj_basic 80 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 81 81 with ubman.log.section('Test Case 4 - load (small)'): 82 82 # Test Case 4a - Read full 1MB of small file 83 83 output = ubman.run_command_list([ 84 84 'host bind 0 %s' % fs_img, 85 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 85 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, SMALL_FILE), 86 86 'printenv filesize']) 87 87 assert('filesize=100000' in ''.join(output)) 88 88 ··· 96 96 """ 97 97 Test Case 5 - load, reading first 1MB of 3GB file 98 98 """ 99 - fs_type,fs_img,md5val = fs_obj_basic 99 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 100 100 with ubman.log.section('Test Case 5 - load (first 1MB)'): 101 101 # Test Case 5a - First 1MB of big file 102 102 output = ubman.run_command_list([ 103 103 'host bind 0 %s' % fs_img, 104 - '%sload host 0:0 %x /%s %x 0x0' % (fs_type, ADDR, BIG_FILE, LENGTH), 104 + '%sload host 0:0 %x /%s %x 0x0' % (fs_cmd_prefix, ADDR, BIG_FILE, LENGTH), 105 105 'printenv filesize']) 106 106 assert('filesize=100000' in ''.join(output)) 107 107 ··· 115 115 """ 116 116 Test Case 6 - load, reading last 1MB of 3GB file 117 117 """ 118 - fs_type,fs_img,md5val = fs_obj_basic 118 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 119 119 with ubman.log.section('Test Case 6 - load (last 1MB)'): 120 120 # fails for ext as no offset support 121 121 # Test Case 6a - Last 1MB of big file 122 122 output = ubman.run_command_list([ 123 123 'host bind 0 %s' % fs_img, 124 124 '%sload host 0:0 %x /%s %x 0x9c300000' 125 - % (fs_type, ADDR, BIG_FILE, LENGTH), 125 + % (fs_cmd_prefix, ADDR, BIG_FILE, LENGTH), 126 126 'printenv filesize']) 127 127 assert('filesize=100000' in ''.join(output)) 128 128 ··· 136 136 """ 137 137 Test Case 7 - load, 1MB from the last 1MB in 2GB 138 138 """ 139 - fs_type,fs_img,md5val = fs_obj_basic 139 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 140 140 with ubman.log.section('Test Case 7 - load (last 1MB in 2GB)'): 141 141 # fails for ext as no offset support 142 142 # Test Case 7a - One from the last 1MB chunk of 2GB 143 143 output = ubman.run_command_list([ 144 144 'host bind 0 %s' % fs_img, 145 145 '%sload host 0:0 %x /%s %x 0x7ff00000' 146 - % (fs_type, ADDR, BIG_FILE, LENGTH), 146 + % (fs_cmd_prefix, ADDR, BIG_FILE, LENGTH), 147 147 'printenv filesize']) 148 148 assert('filesize=100000' in ''.join(output)) 149 149 ··· 157 157 """ 158 158 Test Case 8 - load, reading first 1MB in 2GB 159 159 """ 160 - fs_type,fs_img,md5val = fs_obj_basic 160 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 161 161 with ubman.log.section('Test Case 8 - load (first 1MB in 2GB)'): 162 162 # fails for ext as no offset support 163 163 # Test Case 8a - One from the start 1MB chunk from 2GB 164 164 output = ubman.run_command_list([ 165 165 'host bind 0 %s' % fs_img, 166 166 '%sload host 0:0 %x /%s %x 0x80000000' 167 - % (fs_type, ADDR, BIG_FILE, LENGTH), 167 + % (fs_cmd_prefix, ADDR, BIG_FILE, LENGTH), 168 168 'printenv filesize']) 169 169 assert('filesize=100000' in ''.join(output)) 170 170 ··· 178 178 """ 179 179 Test Case 9 - load, 1MB crossing 2GB boundary 180 180 """ 181 - fs_type,fs_img,md5val = fs_obj_basic 181 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 182 182 with ubman.log.section('Test Case 9 - load (crossing 2GB boundary)'): 183 183 # fails for ext as no offset support 184 184 # Test Case 9a - One 1MB chunk crossing the 2GB boundary 185 185 output = ubman.run_command_list([ 186 186 'host bind 0 %s' % fs_img, 187 187 '%sload host 0:0 %x /%s %x 0x7ff80000' 188 - % (fs_type, ADDR, BIG_FILE, LENGTH), 188 + % (fs_cmd_prefix, ADDR, BIG_FILE, LENGTH), 189 189 'printenv filesize']) 190 190 assert('filesize=100000' in ''.join(output)) 191 191 ··· 199 199 """ 200 200 Test Case 10 - load, reading beyond file end'): 201 201 """ 202 - fs_type,fs_img,md5val = fs_obj_basic 202 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 203 203 with ubman.log.section('Test Case 10 - load (beyond file end)'): 204 204 # Generic failure case 205 205 # Test Case 10 - 2MB chunk from the last 1MB of big file 206 206 output = ubman.run_command_list([ 207 207 'host bind 0 %s' % fs_img, 208 208 '%sload host 0:0 %x /%s 0x00200000 0x9c300000' 209 - % (fs_type, ADDR, BIG_FILE), 209 + % (fs_cmd_prefix, ADDR, BIG_FILE), 210 210 'printenv filesize', 211 211 'md5sum %x $filesize' % ADDR, 212 212 'setenv filesize']) ··· 216 216 """ 217 217 Test Case 11 - write' 218 218 """ 219 - fs_type,fs_img,md5val = fs_obj_basic 219 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 220 220 with ubman.log.section('Test Case 11 - write'): 221 221 # Read 1MB from small file 222 222 # Write it back to test the writes 223 223 # Test Case 11a - Check that the write succeeded 224 224 output = ubman.run_command_list([ 225 225 'host bind 0 %s' % fs_img, 226 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 227 - '%swrite host 0:0 %x /%s.w $filesize' 228 - % (fs_type, ADDR, SMALL_FILE)]) 226 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, SMALL_FILE), 227 + '%s%s host 0:0 %x /%s.w $filesize' 228 + % (fs_cmd_prefix, fs_cmd_write, ADDR, SMALL_FILE)]) 229 229 assert('1048576 bytes written' in ''.join(output)) 230 230 231 231 # Test Case 11b - Check md5 of written to is same 232 232 # as the one read from 233 233 output = ubman.run_command_list([ 234 - '%sload host 0:0 %x /%s.w' % (fs_type, ADDR, SMALL_FILE), 234 + '%sload host 0:0 %x /%s.w' % (fs_cmd_prefix, ADDR, SMALL_FILE), 235 235 'md5sum %x $filesize' % ADDR, 236 236 'setenv filesize']) 237 237 assert(md5val[0] in ''.join(output)) ··· 241 241 """ 242 242 Test Case 12 - write to "." directory 243 243 """ 244 - fs_type,fs_img,md5val = fs_obj_basic 244 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 245 245 with ubman.log.section('Test Case 12 - write (".")'): 246 246 # Next test case checks writing a file whose dirent 247 247 # is the first in the block, which is always true for "." ··· 249 249 # Test Case 12 - Check directory traversal 250 250 output = ubman.run_command_list([ 251 251 'host bind 0 %s' % fs_img, 252 - '%swrite host 0:0 %x /. 0x10' % (fs_type, ADDR)]) 252 + '%s%s host 0:0 %x /. 0x10' 253 + % (fs_cmd_prefix, fs_cmd_write, ADDR)]) 253 254 assert('Unable to write' in ''.join(output)) 254 255 assert_fs_integrity(fs_type, fs_img) 255 256 ··· 257 258 """ 258 259 Test Case 13 - write to a file with "/./<filename>" 259 260 """ 260 - fs_type,fs_img,md5val = fs_obj_basic 261 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_basic 261 262 with ubman.log.section('Test Case 13 - write ("./<file>")'): 262 263 # Read 1MB from small file 263 264 # Write it via "same directory", i.e. "." dirent 264 265 # Test Case 13a - Check directory traversal 265 266 output = ubman.run_command_list([ 266 267 'host bind 0 %s' % fs_img, 267 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 268 - '%swrite host 0:0 %x /./%s2 $filesize' 269 - % (fs_type, ADDR, SMALL_FILE)]) 268 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, SMALL_FILE), 269 + '%s%s host 0:0 %x /./%s2 $filesize' 270 + % (fs_cmd_prefix, fs_cmd_write, ADDR, SMALL_FILE)]) 270 271 assert('1048576 bytes written' in ''.join(output)) 271 272 272 273 # Test Case 13b - Check md5 of written to is same 273 274 # as the one read from 274 275 output = ubman.run_command_list([ 275 276 'mw.b %x 00 100' % ADDR, 276 - '%sload host 0:0 %x /./%s2' % (fs_type, ADDR, SMALL_FILE), 277 + '%sload host 0:0 %x /./%s2' % (fs_cmd_prefix, ADDR, SMALL_FILE), 277 278 'md5sum %x $filesize' % ADDR, 278 279 'setenv filesize']) 279 280 assert(md5val[0] in ''.join(output)) ··· 282 283 # as the one read from 283 284 output = ubman.run_command_list([ 284 285 'mw.b %x 00 100' % ADDR, 285 - '%sload host 0:0 %x /%s2' % (fs_type, ADDR, SMALL_FILE), 286 + '%sload host 0:0 %x /%s2' % (fs_cmd_prefix, ADDR, SMALL_FILE), 286 287 'md5sum %x $filesize' % ADDR, 287 288 'setenv filesize']) 288 289 assert(md5val[0] in ''.join(output))
+78 -78
test/py/tests/test_fs/test_ext.py
··· 33 33 """ 34 34 Test Case 1 - write a file with absolute path 35 35 """ 36 - fs_type,fs_img,md5val = fs_obj_ext 36 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 37 37 with ubman.log.section('Test Case 1 - write with abs path'): 38 38 # Test Case 1a - Check if command successfully returned 39 39 output = ubman.run_command_list([ 40 40 'host bind 0 %s' % fs_img, 41 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 42 - '%swrite host 0:0 %x /dir1/%s.w1 $filesize' 43 - % (fs_type, ADDR, MIN_FILE)]) 41 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 42 + '%s%s host 0:0 %x /dir1/%s.w1 $filesize' 43 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 44 44 assert('20480 bytes written' in ''.join(output)) 45 45 46 46 # Test Case 1b - Check md5 of file content 47 47 output = ubman.run_command_list([ 48 48 'mw.b %x 00 100' % ADDR, 49 - '%sload host 0:0 %x /dir1/%s.w1' % (fs_type, ADDR, MIN_FILE), 49 + '%sload host 0:0 %x /dir1/%s.w1' % (fs_cmd_prefix, ADDR, MIN_FILE), 50 50 'md5sum %x $filesize' % ADDR, 51 51 'setenv filesize']) 52 52 assert(md5val[0] in ''.join(output)) ··· 56 56 """ 57 57 Test Case 2 - write to a file with relative path 58 58 """ 59 - fs_type,fs_img,md5val = fs_obj_ext 59 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 60 60 with ubman.log.section('Test Case 2 - write with rel path'): 61 61 # Test Case 2a - Check if command successfully returned 62 62 output = ubman.run_command_list([ 63 63 'host bind 0 %s' % fs_img, 64 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 65 - '%swrite host 0:0 %x dir1/%s.w2 $filesize' 66 - % (fs_type, ADDR, MIN_FILE)]) 64 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 65 + '%s%s host 0:0 %x dir1/%s.w2 $filesize' 66 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 67 67 assert('20480 bytes written' in ''.join(output)) 68 68 69 69 # Test Case 2b - Check md5 of file content 70 70 output = ubman.run_command_list([ 71 71 'mw.b %x 00 100' % ADDR, 72 - '%sload host 0:0 %x dir1/%s.w2' % (fs_type, ADDR, MIN_FILE), 72 + '%sload host 0:0 %x dir1/%s.w2' % (fs_cmd_prefix, ADDR, MIN_FILE), 73 73 'md5sum %x $filesize' % ADDR, 74 74 'setenv filesize']) 75 75 assert(md5val[0] in ''.join(output)) ··· 79 79 """ 80 80 Test Case 3 - write to a file with invalid path 81 81 """ 82 - fs_type,fs_img,md5val = fs_obj_ext 82 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 83 83 with ubman.log.section('Test Case 3 - write with invalid path'): 84 84 # Test Case 3 - Check if command expectedly failed 85 85 output = ubman.run_command_list([ 86 86 'host bind 0 %s' % fs_img, 87 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 88 - '%swrite host 0:0 %x /dir1/none/%s.w3 $filesize' 89 - % (fs_type, ADDR, MIN_FILE)]) 87 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 88 + '%s%s host 0:0 %x /dir1/none/%s.w3 $filesize' 89 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 90 90 assert('Unable to write file /dir1/none/' in ''.join(output)) 91 91 assert_fs_integrity(fs_type, fs_img) 92 92 ··· 94 94 """ 95 95 Test Case 4 - write at non-zero offset, enlarging file size 96 96 """ 97 - fs_type,fs_img,md5val = fs_obj_ext 97 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 98 98 with ubman.log.section('Test Case 4 - write at non-zero offset, enlarging file size'): 99 99 # Test Case 4a - Check if command successfully returned 100 100 output = ubman.run_command_list([ 101 101 'host bind 0 %s' % fs_img, 102 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 103 - '%swrite host 0:0 %x /dir1/%s.w4 $filesize' 104 - % (fs_type, ADDR, MIN_FILE)]) 102 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 103 + '%s%s host 0:0 %x /dir1/%s.w4 $filesize' 104 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 105 105 output = ubman.run_command( 106 - '%swrite host 0:0 %x /dir1/%s.w4 $filesize 0x1400' 107 - % (fs_type, ADDR, MIN_FILE)) 106 + '%s%s host 0:0 %x /dir1/%s.w4 $filesize 0x1400' 107 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)) 108 108 assert('20480 bytes written' in output) 109 109 110 110 # Test Case 4b - Check size of written file 111 111 output = ubman.run_command_list([ 112 - '%ssize host 0:0 /dir1/%s.w4' % (fs_type, MIN_FILE), 112 + '%ssize host 0:0 /dir1/%s.w4' % (fs_cmd_prefix, MIN_FILE), 113 113 'printenv filesize', 114 114 'setenv filesize']) 115 115 assert('filesize=6400' in ''.join(output)) ··· 117 117 # Test Case 4c - Check md5 of file content 118 118 output = ubman.run_command_list([ 119 119 'mw.b %x 00 100' % ADDR, 120 - '%sload host 0:0 %x /dir1/%s.w4' % (fs_type, ADDR, MIN_FILE), 120 + '%sload host 0:0 %x /dir1/%s.w4' % (fs_cmd_prefix, ADDR, MIN_FILE), 121 121 'md5sum %x $filesize' % ADDR, 122 122 'setenv filesize']) 123 123 assert(md5val[1] in ''.join(output)) ··· 127 127 """ 128 128 Test Case 5 - write at non-zero offset, shrinking file size 129 129 """ 130 - fs_type,fs_img,md5val = fs_obj_ext 130 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 131 131 with ubman.log.section('Test Case 5 - write at non-zero offset, shrinking file size'): 132 132 # Test Case 5a - Check if command successfully returned 133 133 output = ubman.run_command_list([ 134 134 'host bind 0 %s' % fs_img, 135 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 136 - '%swrite host 0:0 %x /dir1/%s.w5 $filesize' 137 - % (fs_type, ADDR, MIN_FILE)]) 135 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 136 + '%s%s host 0:0 %x /dir1/%s.w5 $filesize' 137 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 138 138 output = ubman.run_command( 139 - '%swrite host 0:0 %x /dir1/%s.w5 0x1400 0x1400' 140 - % (fs_type, ADDR, MIN_FILE)) 139 + '%s%s host 0:0 %x /dir1/%s.w5 0x1400 0x1400' 140 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)) 141 141 assert('5120 bytes written' in output) 142 142 143 143 # Test Case 5b - Check size of written file 144 144 output = ubman.run_command_list([ 145 - '%ssize host 0:0 /dir1/%s.w5' % (fs_type, MIN_FILE), 145 + '%ssize host 0:0 /dir1/%s.w5' % (fs_cmd_prefix, MIN_FILE), 146 146 'printenv filesize', 147 147 'setenv filesize']) 148 148 assert('filesize=2800' in ''.join(output)) ··· 150 150 # Test Case 5c - Check md5 of file content 151 151 output = ubman.run_command_list([ 152 152 'mw.b %x 00 100' % ADDR, 153 - '%sload host 0:0 %x /dir1/%s.w5' % (fs_type, ADDR, MIN_FILE), 153 + '%sload host 0:0 %x /dir1/%s.w5' % (fs_cmd_prefix, ADDR, MIN_FILE), 154 154 'md5sum %x $filesize' % ADDR, 155 155 'setenv filesize']) 156 156 assert(md5val[2] in ''.join(output)) ··· 160 160 """ 161 161 Test Case 6 - write nothing at the start, truncating to zero 162 162 """ 163 - fs_type,fs_img,md5val = fs_obj_ext 163 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 164 164 with ubman.log.section('Test Case 6 - write nothing at the start, truncating to zero'): 165 165 # Test Case 6a - Check if command successfully returned 166 166 output = ubman.run_command_list([ 167 167 'host bind 0 %s' % fs_img, 168 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 169 - '%swrite host 0:0 %x /dir1/%s.w6 $filesize' 170 - % (fs_type, ADDR, MIN_FILE)]) 168 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 169 + '%s%s host 0:0 %x /dir1/%s.w6 $filesize' 170 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 171 171 output = ubman.run_command( 172 - '%swrite host 0:0 %x /dir1/%s.w6 0 0' 173 - % (fs_type, ADDR, MIN_FILE)) 172 + '%s%s host 0:0 %x /dir1/%s.w6 0 0' 173 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)) 174 174 assert('0 bytes written' in output) 175 175 176 176 # Test Case 6b - Check size of written file 177 177 output = ubman.run_command_list([ 178 - '%ssize host 0:0 /dir1/%s.w6' % (fs_type, MIN_FILE), 178 + '%ssize host 0:0 /dir1/%s.w6' % (fs_cmd_prefix, MIN_FILE), 179 179 'printenv filesize', 180 180 'setenv filesize']) 181 181 assert('filesize=0' in ''.join(output)) ··· 185 185 """ 186 186 Test Case 7 - write at the end (append) 187 187 """ 188 - fs_type,fs_img,md5val = fs_obj_ext 188 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 189 189 with ubman.log.section('Test Case 7 - write at the end (append)'): 190 190 # Test Case 7a - Check if command successfully returned 191 191 output = ubman.run_command_list([ 192 192 'host bind 0 %s' % fs_img, 193 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 194 - '%swrite host 0:0 %x /dir1/%s.w7 $filesize' 195 - % (fs_type, ADDR, MIN_FILE)]) 193 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 194 + '%s%s host 0:0 %x /dir1/%s.w7 $filesize' 195 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 196 196 output = ubman.run_command( 197 - '%swrite host 0:0 %x /dir1/%s.w7 $filesize $filesize' 198 - % (fs_type, ADDR, MIN_FILE)) 197 + '%s%s host 0:0 %x /dir1/%s.w7 $filesize $filesize' 198 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)) 199 199 assert('20480 bytes written' in output) 200 200 201 201 # Test Case 7b - Check size of written file 202 202 output = ubman.run_command_list([ 203 - '%ssize host 0:0 /dir1/%s.w7' % (fs_type, MIN_FILE), 203 + '%ssize host 0:0 /dir1/%s.w7' % (fs_cmd_prefix, MIN_FILE), 204 204 'printenv filesize', 205 205 'setenv filesize']) 206 206 assert('filesize=a000' in ''.join(output)) ··· 208 208 # Test Case 7c - Check md5 of file content 209 209 output = ubman.run_command_list([ 210 210 'mw.b %x 00 100' % ADDR, 211 - '%sload host 0:0 %x /dir1/%s.w7' % (fs_type, ADDR, MIN_FILE), 211 + '%sload host 0:0 %x /dir1/%s.w7' % (fs_cmd_prefix, ADDR, MIN_FILE), 212 212 'md5sum %x $filesize' % ADDR, 213 213 'setenv filesize']) 214 214 assert(md5val[3] in ''.join(output)) ··· 218 218 """ 219 219 Test Case 8 - write at offset beyond the end of file 220 220 """ 221 - fs_type,fs_img,md5val = fs_obj_ext 221 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 222 222 with ubman.log.section('Test Case 8 - write beyond the end'): 223 223 # Test Case 8a - Check if command expectedly failed 224 224 output = ubman.run_command_list([ 225 225 'host bind 0 %s' % fs_img, 226 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 227 - '%swrite host 0:0 %x /dir1/%s.w8 $filesize' 228 - % (fs_type, ADDR, MIN_FILE)]) 226 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 227 + '%s%s host 0:0 %x /dir1/%s.w8 $filesize' 228 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 229 229 output = ubman.run_command( 230 - '%swrite host 0:0 %x /dir1/%s.w8 0x1400 %x' 231 - % (fs_type, ADDR, MIN_FILE, 0x100000 + 0x1400)) 230 + '%s%s host 0:0 %x /dir1/%s.w8 0x1400 %x' 231 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE, 0x100000 + 0x1400)) 232 232 assert('Unable to write file /dir1' in output) 233 233 assert_fs_integrity(fs_type, fs_img) 234 234 ··· 236 236 """ 237 237 Test Case 9 - write to a non-existing file at non-zero offset 238 238 """ 239 - fs_type,fs_img,md5val = fs_obj_ext 239 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 240 240 with ubman.log.section('Test Case 9 - write to non-existing file with non-zero offset'): 241 241 # Test Case 9a - Check if command expectedly failed 242 242 output = ubman.run_command_list([ 243 243 'host bind 0 %s' % fs_img, 244 - '%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE), 245 - '%swrite host 0:0 %x /dir1/%s.w9 0x1400 0x1400' 246 - % (fs_type, ADDR, MIN_FILE)]) 244 + '%sload host 0:0 %x /%s' % (fs_cmd_prefix, ADDR, MIN_FILE), 245 + '%s%s host 0:0 %x /dir1/%s.w9 0x1400 0x1400' 246 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MIN_FILE)]) 247 247 assert('Unable to write file /dir1' in ''.join(output)) 248 248 assert_fs_integrity(fs_type, fs_img) 249 249 ··· 252 252 'Test Case 10 - create/delete as many directories under root directory 253 253 as amount of directory entries goes beyond one cluster size)' 254 254 """ 255 - fs_type,fs_img,md5val = fs_obj_ext 255 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 256 256 with ubman.log.section('Test Case 10 - create/delete (many)'): 257 257 # Test Case 10a - Create many files 258 258 # Please note that the size of directory entry is 32 bytes. ··· 262 262 263 263 for i in range(0, 66): 264 264 output = ubman.run_command( 265 - '%swrite host 0:0 %x /FILE0123456789_%02x 100' 266 - % (fs_type, ADDR, i)) 267 - output = ubman.run_command('%sls host 0:0 /' % fs_type) 265 + '%s%s host 0:0 %x /FILE0123456789_%02x 100' 266 + % (fs_cmd_prefix, fs_cmd_write, ADDR, i)) 267 + output = ubman.run_command('%sls host 0:0 /' % fs_cmd_prefix) 268 268 assert('FILE0123456789_00' in output) 269 269 assert('FILE0123456789_41' in output) 270 270 ··· 272 272 for i in range(0, 66): 273 273 output = ubman.run_command( 274 274 '%srm host 0:0 /FILE0123456789_%02x' 275 - % (fs_type, i)) 276 - output = ubman.run_command('%sls host 0:0 /' % fs_type) 275 + % (fs_cmd_prefix, i)) 276 + output = ubman.run_command('%sls host 0:0 /' % fs_cmd_prefix) 277 277 assert(not 'FILE0123456789_00' in output) 278 278 assert(not 'FILE0123456789_41' in output) 279 279 ··· 281 281 # Please note no.64 and 65 are intentionally re-created 282 282 for i in range(64, 128): 283 283 output = ubman.run_command( 284 - '%swrite host 0:0 %x /FILE0123456789_%02x 100' 285 - % (fs_type, ADDR, i)) 286 - output = ubman.run_command('%sls host 0:0 /' % fs_type) 284 + '%s%s host 0:0 %x /FILE0123456789_%02x 100' 285 + % (fs_cmd_prefix, fs_cmd_write, ADDR, i)) 286 + output = ubman.run_command('%sls host 0:0 /' % fs_cmd_prefix) 287 287 assert('FILE0123456789_40' in output) 288 288 assert('FILE0123456789_79' in output) 289 289 ··· 294 294 'Test Case 11 - create/delete as many directories under non-root 295 295 directory as amount of directory entries goes beyond one cluster size)' 296 296 """ 297 - fs_type,fs_img,md5val = fs_obj_ext 297 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 298 298 with ubman.log.section('Test Case 11 - create/delete (many)'): 299 299 # Test Case 11a - Create many files 300 300 # Please note that the size of directory entry is 32 bytes. ··· 304 304 305 305 for i in range(0, 66): 306 306 output = ubman.run_command( 307 - '%swrite host 0:0 %x /dir1/FILE0123456789_%02x 100' 308 - % (fs_type, ADDR, i)) 309 - output = ubman.run_command('%sls host 0:0 /dir1' % fs_type) 307 + '%s%s host 0:0 %x /dir1/FILE0123456789_%02x 100' 308 + % (fs_cmd_prefix, fs_cmd_write, ADDR, i)) 309 + output = ubman.run_command('%sls host 0:0 /dir1' % fs_cmd_prefix) 310 310 assert('FILE0123456789_00' in output) 311 311 assert('FILE0123456789_41' in output) 312 312 ··· 314 314 for i in range(0, 66): 315 315 output = ubman.run_command( 316 316 '%srm host 0:0 /dir1/FILE0123456789_%02x' 317 - % (fs_type, i)) 318 - output = ubman.run_command('%sls host 0:0 /dir1' % fs_type) 317 + % (fs_cmd_prefix, i)) 318 + output = ubman.run_command('%sls host 0:0 /dir1' % fs_cmd_prefix) 319 319 assert(not 'FILE0123456789_00' in output) 320 320 assert(not 'FILE0123456789_41' in output) 321 321 ··· 323 323 # Please note no.64 and 65 are intentionally re-created 324 324 for i in range(64, 128): 325 325 output = ubman.run_command( 326 - '%swrite host 0:0 %x /dir1/FILE0123456789_%02x 100' 327 - % (fs_type, ADDR, i)) 328 - output = ubman.run_command('%sls host 0:0 /dir1' % fs_type) 326 + '%s%s host 0:0 %x /dir1/FILE0123456789_%02x 100' 327 + % (fs_cmd_prefix, fs_cmd_write, ADDR, i)) 328 + output = ubman.run_command('%sls host 0:0 /dir1' % fs_cmd_prefix) 329 329 assert('FILE0123456789_40' in output) 330 330 assert('FILE0123456789_79' in output) 331 331 ··· 335 335 """ 336 336 Test Case 12 - write plain and mangle file 337 337 """ 338 - fs_type,fs_img,md5val = fs_obj_ext 338 + fs_type,fs_cmd_prefix,fs_cmd_write,fs_img,md5val = fs_obj_ext 339 339 with ubman.log.section('Test Case 12 - write plain and mangle file'): 340 340 # Test Case 12a - Check if command successfully returned 341 341 output = ubman.run_command_list([ 342 342 'host bind 0 %s' % fs_img, 343 - '%swrite host 0:0 %x /%s 0' 344 - % (fs_type, ADDR, PLAIN_FILE), 345 - '%swrite host 0:0 %x /%s 0' 346 - % (fs_type, ADDR, MANGLE_FILE)]) 343 + '%s%s host 0:0 %x /%s 0' 344 + % (fs_cmd_prefix, fs_cmd_write, ADDR, PLAIN_FILE), 345 + '%s%s host 0:0 %x /%s 0' 346 + % (fs_cmd_prefix, fs_cmd_write, ADDR, MANGLE_FILE)]) 347 347 assert('0 bytes written' in ''.join(output)) 348 348 # Test Case 12b - Read file system content 349 349 output = check_output('mdir -i %s' % fs_img, shell=True).decode()
+21 -21
test/py/tests/test_fs/test_mkdir.py
··· 18 18 """ 19 19 Test Case 1 - create a directory under a root 20 20 """ 21 - fs_type,fs_img = fs_obj_mkdir 21 + fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir 22 22 with ubman.log.section('Test Case 1 - mkdir'): 23 23 output = ubman.run_command_list([ 24 24 'host bind 0 %s' % fs_img, 25 - '%smkdir host 0:0 dir1' % fs_type, 26 - '%sls host 0:0 /' % fs_type]) 25 + '%smkdir host 0:0 dir1' % fs_cmd_prefix, 26 + '%sls host 0:0 /' % fs_cmd_prefix]) 27 27 assert('dir1/' in ''.join(output)) 28 28 29 29 output = ubman.run_command( 30 - '%sls host 0:0 dir1' % fs_type) 30 + '%sls host 0:0 dir1' % fs_cmd_prefix) 31 31 assert('./' in output) 32 32 assert('../' in output) 33 33 assert_fs_integrity(fs_type, fs_img) ··· 37 37 """ 38 38 Test Case 2 - create a directory under a sub-directory 39 39 """ 40 - fs_type,fs_img = fs_obj_mkdir 40 + fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir 41 41 with ubman.log.section('Test Case 2 - mkdir (sub-sub directory)'): 42 42 output = ubman.run_command_list([ 43 43 'host bind 0 %s' % fs_img, 44 - '%smkdir host 0:0 dir1/dir2' % fs_type, 45 - '%sls host 0:0 dir1' % fs_type]) 44 + '%smkdir host 0:0 dir1/dir2' % fs_cmd_prefix, 45 + '%sls host 0:0 dir1' % fs_cmd_prefix]) 46 46 assert('dir2/' in ''.join(output)) 47 47 48 48 output = ubman.run_command( 49 - '%sls host 0:0 dir1/dir2' % fs_type) 49 + '%sls host 0:0 dir1/dir2' % fs_cmd_prefix) 50 50 assert('./' in output) 51 51 assert('../' in output) 52 52 assert_fs_integrity(fs_type, fs_img) ··· 56 56 Test Case 3 - trying to create a directory with a non-existing 57 57 path should fail 58 58 """ 59 - fs_type,fs_img = fs_obj_mkdir 59 + fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir 60 60 with ubman.log.section('Test Case 3 - mkdir (non-existing path)'): 61 61 output = ubman.run_command_list([ 62 62 'host bind 0 %s' % fs_img, 63 - '%smkdir host 0:0 none/dir3' % fs_type]) 63 + '%smkdir host 0:0 none/dir3' % fs_cmd_prefix]) 64 64 assert('Unable to create a directory' in ''.join(output)) 65 65 assert_fs_integrity(fs_type, fs_img) 66 66 ··· 68 68 """ 69 69 Test Case 4 - trying to create "." should fail 70 70 """ 71 - fs_type,fs_img = fs_obj_mkdir 71 + fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir 72 72 with ubman.log.section('Test Case 4 - mkdir (".")'): 73 73 output = ubman.run_command_list([ 74 74 'host bind 0 %s' % fs_img, 75 - '%smkdir host 0:0 .' % fs_type]) 75 + '%smkdir host 0:0 .' % fs_cmd_prefix]) 76 76 assert('Unable to create a directory' in ''.join(output)) 77 77 assert_fs_integrity(fs_type, fs_img) 78 78 ··· 80 80 """ 81 81 Test Case 5 - trying to create ".." should fail 82 82 """ 83 - fs_type,fs_img = fs_obj_mkdir 83 + fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir 84 84 with ubman.log.section('Test Case 5 - mkdir ("..")'): 85 85 output = ubman.run_command_list([ 86 86 'host bind 0 %s' % fs_img, 87 - '%smkdir host 0:0 ..' % fs_type]) 87 + '%smkdir host 0:0 ..' % fs_cmd_prefix]) 88 88 assert('Unable to create a directory' in ''.join(output)) 89 89 assert_fs_integrity(fs_type, fs_img) 90 90 ··· 93 93 'Test Case 6 - create as many directories as amount of directory 94 94 entries goes beyond a cluster size)' 95 95 """ 96 - fs_type,fs_img = fs_obj_mkdir 96 + fs_type,fs_cmd_prefix,fs_img = fs_obj_mkdir 97 97 with ubman.log.section('Test Case 6 - mkdir (create many)'): 98 98 output = ubman.run_command_list([ 99 99 'host bind 0 %s' % fs_img, 100 - '%smkdir host 0:0 dir6' % fs_type, 101 - '%sls host 0:0 /' % fs_type]) 100 + '%smkdir host 0:0 dir6' % fs_cmd_prefix, 101 + '%sls host 0:0 /' % fs_cmd_prefix]) 102 102 assert('dir6/' in ''.join(output)) 103 103 104 104 for i in range(0, 20): 105 105 output = ubman.run_command( 106 106 '%smkdir host 0:0 dir6/0123456789abcdef%02x' 107 - % (fs_type, i)) 108 - output = ubman.run_command('%sls host 0:0 dir6' % fs_type) 107 + % (fs_cmd_prefix, i)) 108 + output = ubman.run_command('%sls host 0:0 dir6' % fs_cmd_prefix) 109 109 assert('0123456789abcdef00/' in output) 110 110 assert('0123456789abcdef13/' in output) 111 111 112 112 output = ubman.run_command( 113 - '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_type) 113 + '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_cmd_prefix) 114 114 assert('./' in output) 115 115 assert('../' in output) 116 116 117 117 output = ubman.run_command( 118 - '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_type) 118 + '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_cmd_prefix) 119 119 assert('0123456789abcdef00/' in output) 120 120 assert('0123456789abcdef13/' in output) 121 121 assert_fs_integrity(fs_type, fs_img)
+19 -19
test/py/tests/test_fs/test_unlink.py
··· 19 19 """ 20 20 Test Case 1 - delete a file 21 21 """ 22 - fs_type,fs_img = fs_obj_unlink 22 + fs_type,fs_cmd_prefix,fs_img = fs_obj_unlink 23 23 with ubman.log.section('Test Case 1 - unlink (file)'): 24 24 output = ubman.run_command_list([ 25 25 'host bind 0 %s' % fs_img, 26 - '%srm host 0:0 dir1/file1' % fs_type, 27 - '%sls host 0:0 dir1/file1' % fs_type]) 26 + '%srm host 0:0 dir1/file1' % fs_cmd_prefix, 27 + '%sls host 0:0 dir1/file1' % fs_cmd_prefix]) 28 28 assert('' == ''.join(output)) 29 29 30 30 output = ubman.run_command( 31 - '%sls host 0:0 dir1/' % fs_type) 31 + '%sls host 0:0 dir1/' % fs_cmd_prefix) 32 32 assert(not 'file1' in output) 33 33 assert('file2' in output) 34 34 assert_fs_integrity(fs_type, fs_img) ··· 37 37 """ 38 38 Test Case 2 - delete many files 39 39 """ 40 - fs_type,fs_img = fs_obj_unlink 40 + fs_type,fs_cmd_prefix,fs_img = fs_obj_unlink 41 41 with ubman.log.section('Test Case 2 - unlink (many)'): 42 42 output = ubman.run_command('host bind 0 %s' % fs_img) 43 43 44 44 for i in range(0, 20): 45 45 output = ubman.run_command_list([ 46 - '%srm host 0:0 dir2/0123456789abcdef%02x' % (fs_type, i), 47 - '%sls host 0:0 dir2/0123456789abcdef%02x' % (fs_type, i)]) 46 + '%srm host 0:0 dir2/0123456789abcdef%02x' % (fs_cmd_prefix, i), 47 + '%sls host 0:0 dir2/0123456789abcdef%02x' % (fs_cmd_prefix, i)]) 48 48 assert('' == ''.join(output)) 49 49 50 50 output = ubman.run_command( 51 - '%sls host 0:0 dir2' % fs_type) 51 + '%sls host 0:0 dir2' % fs_cmd_prefix) 52 52 assert('0 file(s), 2 dir(s)' in output) 53 53 assert_fs_integrity(fs_type, fs_img) 54 54 ··· 56 56 """ 57 57 Test Case 3 - trying to delete a non-existing file should fail 58 58 """ 59 - fs_type,fs_img = fs_obj_unlink 59 + fs_type,fs_cmd_prefix,fs_img = fs_obj_unlink 60 60 with ubman.log.section('Test Case 3 - unlink (non-existing)'): 61 61 output = ubman.run_command_list([ 62 62 'host bind 0 %s' % fs_img, 63 - '%srm host 0:0 dir1/nofile' % fs_type]) 63 + '%srm host 0:0 dir1/nofile' % fs_cmd_prefix]) 64 64 assert('nofile: doesn\'t exist' in ''.join(output)) 65 65 assert_fs_integrity(fs_type, fs_img) 66 66 ··· 68 68 """ 69 69 Test Case 4 - delete an empty directory 70 70 """ 71 - fs_type,fs_img = fs_obj_unlink 71 + fs_type,fs_cmd_prefix,fs_img = fs_obj_unlink 72 72 with ubman.log.section('Test Case 4 - unlink (directory)'): 73 73 output = ubman.run_command_list([ 74 74 'host bind 0 %s' % fs_img, 75 - '%srm host 0:0 dir4' % fs_type]) 75 + '%srm host 0:0 dir4' % fs_cmd_prefix]) 76 76 assert('' == ''.join(output)) 77 77 78 78 output = ubman.run_command( 79 - '%sls host 0:0 /' % fs_type) 79 + '%sls host 0:0 /' % fs_cmd_prefix) 80 80 assert(not 'dir4' in output) 81 81 assert_fs_integrity(fs_type, fs_img) 82 82 ··· 85 85 Test Case 5 - trying to deleting a non-empty directory ".." 86 86 should fail 87 87 """ 88 - fs_type,fs_img = fs_obj_unlink 88 + fs_type,fs_cmd_prefix,fs_img = fs_obj_unlink 89 89 with ubman.log.section('Test Case 5 - unlink ("non-empty directory")'): 90 90 output = ubman.run_command_list([ 91 91 'host bind 0 %s' % fs_img, 92 - '%srm host 0:0 dir5' % fs_type]) 92 + '%srm host 0:0 dir5' % fs_cmd_prefix]) 93 93 assert('directory is not empty' in ''.join(output)) 94 94 assert_fs_integrity(fs_type, fs_img) 95 95 ··· 97 97 """ 98 98 Test Case 6 - trying to deleting a "." should fail 99 99 """ 100 - fs_type,fs_img = fs_obj_unlink 100 + fs_type,fs_cmd_prefix,fs_img = fs_obj_unlink 101 101 with ubman.log.section('Test Case 6 - unlink (".")'): 102 102 output = ubman.run_command_list([ 103 103 'host bind 0 %s' % fs_img, 104 - '%srm host 0:0 dir5/.' % fs_type]) 104 + '%srm host 0:0 dir5/.' % fs_cmd_prefix]) 105 105 assert('directory is not empty' in ''.join(output)) 106 106 assert_fs_integrity(fs_type, fs_img) 107 107 ··· 109 109 """ 110 110 Test Case 7 - trying to deleting a ".." should fail 111 111 """ 112 - fs_type,fs_img = fs_obj_unlink 112 + fs_type,fs_cmd_prefix,fs_img = fs_obj_unlink 113 113 with ubman.log.section('Test Case 7 - unlink ("..")'): 114 114 output = ubman.run_command_list([ 115 115 'host bind 0 %s' % fs_img, 116 - '%srm host 0:0 dir5/..' % fs_type]) 116 + '%srm host 0:0 dir5/..' % fs_cmd_prefix]) 117 117 assert('directory is not empty' in ''.join(output)) 118 118 assert_fs_integrity(fs_type, fs_img)