Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | # SPDX-License-Identifier: GPL-2.0+ # Copyright (c) 2018, Linaro Limited # Author: Takahiro Akashi <takahiro.akashi@linaro.org> # # U-Boot File System:Exntented Test """ This test verifies extended write operation on file system. """ import pytest import re from fstest_defs import * from fstest_helpers import assert_fs_integrity @pytest.mark.boardspec('sandbox') @pytest.mark.slow class TestFsExt(object): def test_fs_ext1(self, u_boot_console, fs_obj_ext): """ Test Case 1 - write a file with absolute path """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 1 - write with abs path'): # Test Case 1a - 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.w1 $filesize' % (fs_type, ADDR, MIN_FILE)]) assert('20480 bytes written' in ''.join(output)) # Test Case 1b - 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.w1' % (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_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_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_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_fs_ext5(self, u_boot_console, fs_obj_ext): """ Test Case 5 - write at non-zero offset, shrinking file size """ fs_type,fs_img,md5val = fs_obj_ext with u_boot_console.log.section('Test Case 5 - write at non-zero offset, shrinking file size'): # Test Case 5a - 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.w5 $filesize' % (fs_type, ADDR, MIN_FILE)]) output = u_boot_console.run_command( '%swrite host 0:0 %x /dir1/%s.w5 0x1400 0x1400' % (fs_type, ADDR, MIN_FILE)) assert('5120 bytes written' in output) # Test Case 5b - Check size of written file output = u_boot_console.run_command_list([ '%ssize host 0:0 /dir1/%s.w5' % (fs_type, MIN_FILE), 'printenv filesize', 'setenv filesize']) assert('filesize=2800' in ''.join(output)) # Test Case 5c - 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.w5' % (fs_type, ADDR, MIN_FILE), 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[2] 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_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_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_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) |