AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
| 2 | # Copyright (c) 2018, Linaro Limited |
| 3 | # Author: Takahiro Akashi <takahiro.akashi@linaro.org> |
| 4 | |
| 5 | import os |
| 6 | import os.path |
| 7 | import pytest |
| 8 | import re |
| 9 | from subprocess import call, check_call, check_output, CalledProcessError |
| 10 | from fstest_defs import * |
| 11 | |
| 12 | supported_fs_basic = ['fat16', 'fat32', 'ext4'] |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 13 | supported_fs_ext = ['fat16', 'fat32'] |
AKASHI Takahiro | 1e90c2c | 2018-09-11 15:59:21 +0900 | [diff] [blame] | 14 | supported_fs_mkdir = ['fat16', 'fat32'] |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 15 | supported_fs_unlink = ['fat16', 'fat32'] |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 16 | supported_fs_symlink = ['ext4'] |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 17 | |
| 18 | # |
| 19 | # Filesystem test specific setup |
| 20 | # |
| 21 | def pytest_addoption(parser): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 22 | """Enable --fs-type option. |
| 23 | |
| 24 | See pytest_configure() about how it works. |
| 25 | |
| 26 | Args: |
| 27 | parser: Pytest command-line parser. |
| 28 | |
| 29 | Returns: |
| 30 | Nothing. |
| 31 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 32 | parser.addoption('--fs-type', action='append', default=None, |
| 33 | help='Targeting Filesystem Types') |
| 34 | |
| 35 | def pytest_configure(config): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 36 | """Restrict a file system(s) to be tested. |
| 37 | |
| 38 | A file system explicitly named with --fs-type option is selected |
| 39 | if it belongs to a default supported_fs_xxx list. |
| 40 | Multiple options can be specified. |
| 41 | |
| 42 | Args: |
| 43 | config: Pytest configuration. |
| 44 | |
| 45 | Returns: |
| 46 | Nothing. |
| 47 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 48 | global supported_fs_basic |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 49 | global supported_fs_ext |
AKASHI Takahiro | 1e90c2c | 2018-09-11 15:59:21 +0900 | [diff] [blame] | 50 | global supported_fs_mkdir |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 51 | global supported_fs_unlink |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 52 | global supported_fs_symlink |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 53 | |
| 54 | def intersect(listA, listB): |
| 55 | return [x for x in listA if x in listB] |
| 56 | |
| 57 | supported_fs = config.getoption('fs_type') |
| 58 | if supported_fs: |
Simon Glass | e9f4d87 | 2018-12-27 08:11:13 -0700 | [diff] [blame] | 59 | print('*** FS TYPE modified: %s' % supported_fs) |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 60 | supported_fs_basic = intersect(supported_fs, supported_fs_basic) |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 61 | supported_fs_ext = intersect(supported_fs, supported_fs_ext) |
AKASHI Takahiro | 1e90c2c | 2018-09-11 15:59:21 +0900 | [diff] [blame] | 62 | supported_fs_mkdir = intersect(supported_fs, supported_fs_mkdir) |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 63 | supported_fs_unlink = intersect(supported_fs, supported_fs_unlink) |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 64 | supported_fs_symlink = intersect(supported_fs, supported_fs_symlink) |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 65 | |
| 66 | def pytest_generate_tests(metafunc): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 67 | """Parametrize fixtures, fs_obj_xxx |
| 68 | |
| 69 | Each fixture will be parametrized with a corresponding support_fs_xxx |
| 70 | list. |
| 71 | |
| 72 | Args: |
| 73 | metafunc: Pytest test function. |
| 74 | |
| 75 | Returns: |
| 76 | Nothing. |
| 77 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 78 | if 'fs_obj_basic' in metafunc.fixturenames: |
| 79 | metafunc.parametrize('fs_obj_basic', supported_fs_basic, |
| 80 | indirect=True, scope='module') |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 81 | if 'fs_obj_ext' in metafunc.fixturenames: |
| 82 | metafunc.parametrize('fs_obj_ext', supported_fs_ext, |
| 83 | indirect=True, scope='module') |
AKASHI Takahiro | 1e90c2c | 2018-09-11 15:59:21 +0900 | [diff] [blame] | 84 | if 'fs_obj_mkdir' in metafunc.fixturenames: |
| 85 | metafunc.parametrize('fs_obj_mkdir', supported_fs_mkdir, |
| 86 | indirect=True, scope='module') |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 87 | if 'fs_obj_unlink' in metafunc.fixturenames: |
| 88 | metafunc.parametrize('fs_obj_unlink', supported_fs_unlink, |
| 89 | indirect=True, scope='module') |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 90 | if 'fs_obj_symlink' in metafunc.fixturenames: |
| 91 | metafunc.parametrize('fs_obj_symlink', supported_fs_symlink, |
| 92 | indirect=True, scope='module') |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 93 | |
| 94 | # |
| 95 | # Helper functions |
| 96 | # |
| 97 | def fstype_to_ubname(fs_type): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 98 | """Convert a file system type to an U-boot specific string |
| 99 | |
| 100 | A generated string can be used as part of file system related commands |
| 101 | or a config name in u-boot. Currently fat16 and fat32 are handled |
| 102 | specifically. |
| 103 | |
| 104 | Args: |
| 105 | fs_type: File system type. |
| 106 | |
| 107 | Return: |
| 108 | A corresponding string for file system type. |
| 109 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 110 | if re.match('fat', fs_type): |
| 111 | return 'fat' |
| 112 | else: |
| 113 | return fs_type |
| 114 | |
| 115 | def check_ubconfig(config, fs_type): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 116 | """Check whether a file system is enabled in u-boot configuration. |
| 117 | |
| 118 | This function is assumed to be called in a fixture function so that |
| 119 | the whole test cases will be skipped if a given file system is not |
| 120 | enabled. |
| 121 | |
| 122 | Args: |
| 123 | fs_type: File system type. |
| 124 | |
| 125 | Return: |
| 126 | Nothing. |
| 127 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 128 | if not config.buildconfig.get('config_cmd_%s' % fs_type, None): |
| 129 | pytest.skip('.config feature "CMD_%s" not enabled' % fs_type.upper()) |
| 130 | if not config.buildconfig.get('config_%s_write' % fs_type, None): |
| 131 | pytest.skip('.config feature "%s_WRITE" not enabled' |
| 132 | % fs_type.upper()) |
| 133 | |
| 134 | def mk_fs(config, fs_type, size, id): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 135 | """Create a file system volume. |
| 136 | |
| 137 | Args: |
| 138 | fs_type: File system type. |
| 139 | size: Size of file system in MiB. |
| 140 | id: Prefix string of volume's file name. |
| 141 | |
| 142 | Return: |
| 143 | Nothing. |
| 144 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 145 | fs_img = '%s.%s.img' % (id, fs_type) |
| 146 | fs_img = config.persistent_data_dir + '/' + fs_img |
| 147 | |
| 148 | if fs_type == 'fat16': |
| 149 | mkfs_opt = '-F 16' |
| 150 | elif fs_type == 'fat32': |
| 151 | mkfs_opt = '-F 32' |
| 152 | else: |
| 153 | mkfs_opt = '' |
| 154 | |
| 155 | if re.match('fat', fs_type): |
| 156 | fs_lnxtype = 'vfat' |
| 157 | else: |
| 158 | fs_lnxtype = fs_type |
| 159 | |
| 160 | count = (size + 1048576 - 1) / 1048576 |
| 161 | |
Andy Shevchenko | 70e473f | 2021-06-10 18:08:42 +0300 | [diff] [blame] | 162 | # Some distributions do not add /sbin to the default PATH, where mkfs lives |
| 163 | if '/sbin' not in os.environ["PATH"].split(os.pathsep): |
| 164 | os.environ["PATH"] += os.pathsep + '/sbin' |
| 165 | |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 166 | try: |
| 167 | check_call('rm -f %s' % fs_img, shell=True) |
| 168 | check_call('dd if=/dev/zero of=%s bs=1M count=%d' |
| 169 | % (fs_img, count), shell=True) |
| 170 | check_call('mkfs.%s %s %s' |
| 171 | % (fs_lnxtype, mkfs_opt, fs_img), shell=True) |
Stephen Warren | f7d1093 | 2020-08-04 11:28:33 -0600 | [diff] [blame] | 172 | if fs_type == 'ext4': |
| 173 | sb_content = check_output('tune2fs -l %s' % fs_img, shell=True).decode() |
| 174 | if 'metadata_csum' in sb_content: |
| 175 | check_call('tune2fs -O ^metadata_csum %s' % fs_img, shell=True) |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 176 | return fs_img |
| 177 | except CalledProcessError: |
| 178 | call('rm -f %s' % fs_img, shell=True) |
| 179 | raise |
| 180 | |
| 181 | # from test/py/conftest.py |
| 182 | def tool_is_in_path(tool): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 183 | """Check whether a given command is available on host. |
| 184 | |
| 185 | Args: |
| 186 | tool: Command name. |
| 187 | |
| 188 | Return: |
| 189 | True if available, False if not. |
| 190 | """ |
Simon Glass | e9f4d87 | 2018-12-27 08:11:13 -0700 | [diff] [blame] | 191 | for path in os.environ['PATH'].split(os.pathsep): |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 192 | fn = os.path.join(path, tool) |
| 193 | if os.path.isfile(fn) and os.access(fn, os.X_OK): |
| 194 | return True |
| 195 | return False |
| 196 | |
| 197 | fuse_mounted = False |
| 198 | |
| 199 | def mount_fs(fs_type, device, mount_point): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 200 | """Mount a volume. |
| 201 | |
| 202 | Args: |
| 203 | fs_type: File system type. |
| 204 | device: Volume's file name. |
| 205 | mount_point: Mount point. |
| 206 | |
| 207 | Return: |
| 208 | Nothing. |
| 209 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 210 | global fuse_mounted |
| 211 | |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 212 | try: |
Alper Nebi Yasak | 3dec7a5 | 2021-06-04 22:04:45 +0300 | [diff] [blame^] | 213 | check_call('guestmount -a %s -m /dev/sda %s' |
| 214 | % (device, mount_point), shell=True) |
| 215 | fuse_mounted = True |
| 216 | return |
| 217 | except CalledProcessError: |
| 218 | fuse_mounted = False |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 219 | |
Alper Nebi Yasak | 3dec7a5 | 2021-06-04 22:04:45 +0300 | [diff] [blame^] | 220 | mount_opt = 'loop,rw' |
| 221 | if re.match('fat', fs_type): |
| 222 | mount_opt += ',umask=0000' |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 223 | |
Alper Nebi Yasak | 3dec7a5 | 2021-06-04 22:04:45 +0300 | [diff] [blame^] | 224 | check_call('sudo mount -o %s %s %s' |
| 225 | % (mount_opt, device, mount_point), shell=True) |
| 226 | |
| 227 | # may not be effective for some file systems |
| 228 | check_call('sudo chmod a+rw %s' % mount_point, shell=True) |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 229 | |
Akashi Takahiro | 89101f8 | 2018-09-27 16:07:22 +0900 | [diff] [blame] | 230 | def umount_fs(mount_point): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 231 | """Unmount a volume. |
| 232 | |
| 233 | Args: |
| 234 | mount_point: Mount point. |
| 235 | |
| 236 | Return: |
| 237 | Nothing. |
| 238 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 239 | if fuse_mounted: |
| 240 | call('sync') |
| 241 | call('guestunmount %s' % mount_point, shell=True) |
| 242 | else: |
| 243 | call('sudo umount %s' % mount_point, shell=True) |
| 244 | |
| 245 | # |
| 246 | # Fixture for basic fs test |
| 247 | # derived from test/fs/fs-test.sh |
| 248 | # |
Tom Rini | 1b91cee | 2021-01-28 14:39:56 -0500 | [diff] [blame] | 249 | @pytest.fixture() |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 250 | def fs_obj_basic(request, u_boot_config): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 251 | """Set up a file system to be used in basic fs test. |
| 252 | |
| 253 | Args: |
| 254 | request: Pytest request object. |
| 255 | u_boot_config: U-boot configuration. |
| 256 | |
| 257 | Return: |
| 258 | A fixture for basic fs test, i.e. a triplet of file system type, |
| 259 | volume file name and a list of MD5 hashes. |
| 260 | """ |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 261 | fs_type = request.param |
| 262 | fs_img = '' |
| 263 | |
| 264 | fs_ubtype = fstype_to_ubname(fs_type) |
| 265 | check_ubconfig(u_boot_config, fs_ubtype) |
| 266 | |
| 267 | mount_dir = u_boot_config.persistent_data_dir + '/mnt' |
| 268 | |
| 269 | small_file = mount_dir + '/' + SMALL_FILE |
| 270 | big_file = mount_dir + '/' + BIG_FILE |
| 271 | |
| 272 | try: |
| 273 | |
| 274 | # 3GiB volume |
| 275 | fs_img = mk_fs(u_boot_config, fs_type, 0xc0000000, '3GB') |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 276 | except CalledProcessError as err: |
| 277 | pytest.skip('Creating failed for filesystem: ' + fs_type + '. {}'.format(err)) |
| 278 | return |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 279 | |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 280 | try: |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 281 | check_call('mkdir -p %s' % mount_dir, shell=True) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 282 | except CalledProcessError as err: |
| 283 | pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 284 | call('rm -f %s' % fs_img, shell=True) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 285 | return |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 286 | |
| 287 | try: |
| 288 | # Mount the image so we can populate it. |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 289 | mount_fs(fs_type, fs_img, mount_dir) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 290 | except CalledProcessError as err: |
| 291 | pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) |
| 292 | call('rmdir %s' % mount_dir, shell=True) |
| 293 | call('rm -f %s' % fs_img, shell=True) |
| 294 | return |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 295 | |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 296 | try: |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 297 | # Create a subdirectory. |
| 298 | check_call('mkdir %s/SUBDIR' % mount_dir, shell=True) |
| 299 | |
| 300 | # Create big file in this image. |
| 301 | # Note that we work only on the start 1MB, couple MBs in the 2GB range |
| 302 | # and the last 1 MB of the huge 2.5GB file. |
| 303 | # So, just put random values only in those areas. |
| 304 | check_call('dd if=/dev/urandom of=%s bs=1M count=1' |
| 305 | % big_file, shell=True) |
| 306 | check_call('dd if=/dev/urandom of=%s bs=1M count=2 seek=2047' |
| 307 | % big_file, shell=True) |
| 308 | check_call('dd if=/dev/urandom of=%s bs=1M count=1 seek=2499' |
| 309 | % big_file, shell=True) |
| 310 | |
| 311 | # Create a small file in this image. |
| 312 | check_call('dd if=/dev/urandom of=%s bs=1M count=1' |
| 313 | % small_file, shell=True) |
| 314 | |
| 315 | # Delete the small file copies which possibly are written as part of a |
| 316 | # previous test. |
| 317 | # check_call('rm -f "%s.w"' % MB1, shell=True) |
| 318 | # check_call('rm -f "%s.w2"' % MB1, shell=True) |
| 319 | |
| 320 | # Generate the md5sums of reads that we will test against small file |
| 321 | out = check_output( |
| 322 | 'dd if=%s bs=1M skip=0 count=1 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 323 | % small_file, shell=True).decode() |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 324 | md5val = [ out.split()[0] ] |
| 325 | |
| 326 | # Generate the md5sums of reads that we will test against big file |
| 327 | # One from beginning of file. |
| 328 | out = check_output( |
| 329 | 'dd if=%s bs=1M skip=0 count=1 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 330 | % big_file, shell=True).decode() |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 331 | md5val.append(out.split()[0]) |
| 332 | |
| 333 | # One from end of file. |
| 334 | out = check_output( |
| 335 | 'dd if=%s bs=1M skip=2499 count=1 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 336 | % big_file, shell=True).decode() |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 337 | md5val.append(out.split()[0]) |
| 338 | |
| 339 | # One from the last 1MB chunk of 2GB |
| 340 | out = check_output( |
| 341 | 'dd if=%s bs=1M skip=2047 count=1 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 342 | % big_file, shell=True).decode() |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 343 | md5val.append(out.split()[0]) |
| 344 | |
| 345 | # One from the start 1MB chunk from 2GB |
| 346 | out = check_output( |
| 347 | 'dd if=%s bs=1M skip=2048 count=1 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 348 | % big_file, shell=True).decode() |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 349 | md5val.append(out.split()[0]) |
| 350 | |
| 351 | # One 1MB chunk crossing the 2GB boundary |
| 352 | out = check_output( |
| 353 | 'dd if=%s bs=512K skip=4095 count=2 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 354 | % big_file, shell=True).decode() |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 355 | md5val.append(out.split()[0]) |
| 356 | |
Heinrich Schuchardt | bc85617 | 2020-04-20 20:48:40 +0200 | [diff] [blame] | 357 | except CalledProcessError as err: |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 358 | pytest.skip('Setup failed for filesystem: ' + fs_type + '. {}'.format(err)) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 359 | umount_fs(mount_dir) |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 360 | return |
| 361 | else: |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 362 | umount_fs(mount_dir) |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 363 | yield [fs_ubtype, fs_img, md5val] |
| 364 | finally: |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 365 | call('rmdir %s' % mount_dir, shell=True) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 366 | call('rm -f %s' % fs_img, shell=True) |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 367 | |
| 368 | # |
| 369 | # Fixture for extended fs test |
| 370 | # |
Tom Rini | 1b91cee | 2021-01-28 14:39:56 -0500 | [diff] [blame] | 371 | @pytest.fixture() |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 372 | def fs_obj_ext(request, u_boot_config): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 373 | """Set up a file system to be used in extended fs test. |
| 374 | |
| 375 | Args: |
| 376 | request: Pytest request object. |
| 377 | u_boot_config: U-boot configuration. |
| 378 | |
| 379 | Return: |
| 380 | A fixture for extended fs test, i.e. a triplet of file system type, |
| 381 | volume file name and a list of MD5 hashes. |
| 382 | """ |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 383 | fs_type = request.param |
| 384 | fs_img = '' |
| 385 | |
| 386 | fs_ubtype = fstype_to_ubname(fs_type) |
| 387 | check_ubconfig(u_boot_config, fs_ubtype) |
| 388 | |
| 389 | mount_dir = u_boot_config.persistent_data_dir + '/mnt' |
| 390 | |
| 391 | min_file = mount_dir + '/' + MIN_FILE |
| 392 | tmp_file = mount_dir + '/tmpfile' |
| 393 | |
| 394 | try: |
| 395 | |
| 396 | # 128MiB volume |
| 397 | fs_img = mk_fs(u_boot_config, fs_type, 0x8000000, '128MB') |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 398 | except CalledProcessError as err: |
| 399 | pytest.skip('Creating failed for filesystem: ' + fs_type + '. {}'.format(err)) |
| 400 | return |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 401 | |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 402 | try: |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 403 | check_call('mkdir -p %s' % mount_dir, shell=True) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 404 | except CalledProcessError as err: |
| 405 | pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 406 | call('rm -f %s' % fs_img, shell=True) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 407 | return |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 408 | |
| 409 | try: |
| 410 | # Mount the image so we can populate it. |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 411 | mount_fs(fs_type, fs_img, mount_dir) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 412 | except CalledProcessError as err: |
| 413 | pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) |
| 414 | call('rmdir %s' % mount_dir, shell=True) |
| 415 | call('rm -f %s' % fs_img, shell=True) |
| 416 | return |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 417 | |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 418 | try: |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 419 | # Create a test directory |
| 420 | check_call('mkdir %s/dir1' % mount_dir, shell=True) |
| 421 | |
| 422 | # Create a small file and calculate md5 |
| 423 | check_call('dd if=/dev/urandom of=%s bs=1K count=20' |
| 424 | % min_file, shell=True) |
| 425 | out = check_output( |
| 426 | 'dd if=%s bs=1K 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 427 | % min_file, shell=True).decode() |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 428 | md5val = [ out.split()[0] ] |
| 429 | |
| 430 | # Calculate md5sum of Test Case 4 |
| 431 | check_call('dd if=%s of=%s bs=1K count=20' |
| 432 | % (min_file, tmp_file), shell=True) |
| 433 | check_call('dd if=%s of=%s bs=1K seek=5 count=20' |
| 434 | % (min_file, tmp_file), shell=True) |
| 435 | out = check_output('dd if=%s bs=1K 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 436 | % tmp_file, shell=True).decode() |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 437 | md5val.append(out.split()[0]) |
| 438 | |
| 439 | # Calculate md5sum of Test Case 5 |
| 440 | check_call('dd if=%s of=%s bs=1K count=20' |
| 441 | % (min_file, tmp_file), shell=True) |
| 442 | check_call('dd if=%s of=%s bs=1K seek=5 count=5' |
| 443 | % (min_file, tmp_file), shell=True) |
| 444 | out = check_output('dd if=%s bs=1K 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 445 | % tmp_file, shell=True).decode() |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 446 | md5val.append(out.split()[0]) |
| 447 | |
| 448 | # Calculate md5sum of Test Case 7 |
| 449 | check_call('dd if=%s of=%s bs=1K count=20' |
| 450 | % (min_file, tmp_file), shell=True) |
| 451 | check_call('dd if=%s of=%s bs=1K seek=20 count=20' |
| 452 | % (min_file, tmp_file), shell=True) |
| 453 | out = check_output('dd if=%s bs=1K 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 454 | % tmp_file, shell=True).decode() |
AKASHI Takahiro | dde5d3f | 2018-09-11 15:59:20 +0900 | [diff] [blame] | 455 | md5val.append(out.split()[0]) |
| 456 | |
| 457 | check_call('rm %s' % tmp_file, shell=True) |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 458 | except CalledProcessError: |
| 459 | pytest.skip('Setup failed for filesystem: ' + fs_type) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 460 | umount_fs(mount_dir) |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 461 | return |
| 462 | else: |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 463 | umount_fs(mount_dir) |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 464 | yield [fs_ubtype, fs_img, md5val] |
| 465 | finally: |
AKASHI Takahiro | 615af9a | 2018-09-11 15:59:19 +0900 | [diff] [blame] | 466 | call('rmdir %s' % mount_dir, shell=True) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 467 | call('rm -f %s' % fs_img, shell=True) |
AKASHI Takahiro | 1e90c2c | 2018-09-11 15:59:21 +0900 | [diff] [blame] | 468 | |
| 469 | # |
| 470 | # Fixture for mkdir test |
| 471 | # |
Tom Rini | 1b91cee | 2021-01-28 14:39:56 -0500 | [diff] [blame] | 472 | @pytest.fixture() |
AKASHI Takahiro | 1e90c2c | 2018-09-11 15:59:21 +0900 | [diff] [blame] | 473 | def fs_obj_mkdir(request, u_boot_config): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 474 | """Set up a file system to be used in mkdir test. |
| 475 | |
| 476 | Args: |
| 477 | request: Pytest request object. |
| 478 | u_boot_config: U-boot configuration. |
| 479 | |
| 480 | Return: |
| 481 | A fixture for mkdir test, i.e. a duplet of file system type and |
| 482 | volume file name. |
| 483 | """ |
AKASHI Takahiro | 1e90c2c | 2018-09-11 15:59:21 +0900 | [diff] [blame] | 484 | fs_type = request.param |
| 485 | fs_img = '' |
| 486 | |
| 487 | fs_ubtype = fstype_to_ubname(fs_type) |
| 488 | check_ubconfig(u_boot_config, fs_ubtype) |
| 489 | |
| 490 | try: |
| 491 | # 128MiB volume |
| 492 | fs_img = mk_fs(u_boot_config, fs_type, 0x8000000, '128MB') |
| 493 | except: |
| 494 | pytest.skip('Setup failed for filesystem: ' + fs_type) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 495 | return |
AKASHI Takahiro | 1e90c2c | 2018-09-11 15:59:21 +0900 | [diff] [blame] | 496 | else: |
| 497 | yield [fs_ubtype, fs_img] |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 498 | call('rm -f %s' % fs_img, shell=True) |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 499 | |
| 500 | # |
| 501 | # Fixture for unlink test |
| 502 | # |
Tom Rini | 1b91cee | 2021-01-28 14:39:56 -0500 | [diff] [blame] | 503 | @pytest.fixture() |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 504 | def fs_obj_unlink(request, u_boot_config): |
Akashi Takahiro | bcdd1f2 | 2018-09-27 16:07:23 +0900 | [diff] [blame] | 505 | """Set up a file system to be used in unlink test. |
| 506 | |
| 507 | Args: |
| 508 | request: Pytest request object. |
| 509 | u_boot_config: U-boot configuration. |
| 510 | |
| 511 | Return: |
| 512 | A fixture for unlink test, i.e. a duplet of file system type and |
| 513 | volume file name. |
| 514 | """ |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 515 | fs_type = request.param |
| 516 | fs_img = '' |
| 517 | |
| 518 | fs_ubtype = fstype_to_ubname(fs_type) |
| 519 | check_ubconfig(u_boot_config, fs_ubtype) |
| 520 | |
| 521 | mount_dir = u_boot_config.persistent_data_dir + '/mnt' |
| 522 | |
| 523 | try: |
| 524 | |
| 525 | # 128MiB volume |
| 526 | fs_img = mk_fs(u_boot_config, fs_type, 0x8000000, '128MB') |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 527 | except CalledProcessError as err: |
| 528 | pytest.skip('Creating failed for filesystem: ' + fs_type + '. {}'.format(err)) |
| 529 | return |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 530 | |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 531 | try: |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 532 | check_call('mkdir -p %s' % mount_dir, shell=True) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 533 | except CalledProcessError as err: |
| 534 | pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 535 | call('rm -f %s' % fs_img, shell=True) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 536 | return |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 537 | |
| 538 | try: |
| 539 | # Mount the image so we can populate it. |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 540 | mount_fs(fs_type, fs_img, mount_dir) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 541 | except CalledProcessError as err: |
| 542 | pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) |
| 543 | call('rmdir %s' % mount_dir, shell=True) |
| 544 | call('rm -f %s' % fs_img, shell=True) |
| 545 | return |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 546 | |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 547 | try: |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 548 | # Test Case 1 & 3 |
| 549 | check_call('mkdir %s/dir1' % mount_dir, shell=True) |
| 550 | check_call('dd if=/dev/urandom of=%s/dir1/file1 bs=1K count=1' |
| 551 | % mount_dir, shell=True) |
| 552 | check_call('dd if=/dev/urandom of=%s/dir1/file2 bs=1K count=1' |
| 553 | % mount_dir, shell=True) |
| 554 | |
| 555 | # Test Case 2 |
| 556 | check_call('mkdir %s/dir2' % mount_dir, shell=True) |
Tom Rini | 7f24c19 | 2019-10-24 11:59:20 -0400 | [diff] [blame] | 557 | for i in range(0, 20): |
| 558 | check_call('mkdir %s/dir2/0123456789abcdef%02x' |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 559 | % (mount_dir, i), shell=True) |
| 560 | |
| 561 | # Test Case 4 |
| 562 | check_call('mkdir %s/dir4' % mount_dir, shell=True) |
| 563 | |
| 564 | # Test Case 5, 6 & 7 |
| 565 | check_call('mkdir %s/dir5' % mount_dir, shell=True) |
| 566 | check_call('dd if=/dev/urandom of=%s/dir5/file1 bs=1K count=1' |
| 567 | % mount_dir, shell=True) |
| 568 | |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 569 | except CalledProcessError: |
| 570 | pytest.skip('Setup failed for filesystem: ' + fs_type) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 571 | umount_fs(mount_dir) |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 572 | return |
| 573 | else: |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 574 | umount_fs(mount_dir) |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 575 | yield [fs_ubtype, fs_img] |
| 576 | finally: |
Akashi, Takahiro | d49e799 | 2018-09-11 16:06:03 +0900 | [diff] [blame] | 577 | call('rmdir %s' % mount_dir, shell=True) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 578 | call('rm -f %s' % fs_img, shell=True) |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 579 | |
| 580 | # |
| 581 | # Fixture for symlink fs test |
| 582 | # |
Tom Rini | 1b91cee | 2021-01-28 14:39:56 -0500 | [diff] [blame] | 583 | @pytest.fixture() |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 584 | def fs_obj_symlink(request, u_boot_config): |
| 585 | """Set up a file system to be used in symlink fs test. |
| 586 | |
| 587 | Args: |
| 588 | request: Pytest request object. |
| 589 | u_boot_config: U-boot configuration. |
| 590 | |
| 591 | Return: |
| 592 | A fixture for basic fs test, i.e. a triplet of file system type, |
| 593 | volume file name and a list of MD5 hashes. |
| 594 | """ |
| 595 | fs_type = request.param |
| 596 | fs_img = '' |
| 597 | |
| 598 | fs_ubtype = fstype_to_ubname(fs_type) |
| 599 | check_ubconfig(u_boot_config, fs_ubtype) |
| 600 | |
| 601 | mount_dir = u_boot_config.persistent_data_dir + '/mnt' |
| 602 | |
| 603 | small_file = mount_dir + '/' + SMALL_FILE |
| 604 | medium_file = mount_dir + '/' + MEDIUM_FILE |
| 605 | |
| 606 | try: |
| 607 | |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 608 | # 1GiB volume |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 609 | fs_img = mk_fs(u_boot_config, fs_type, 0x40000000, '1GB') |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 610 | except CalledProcessError as err: |
| 611 | pytest.skip('Creating failed for filesystem: ' + fs_type + '. {}'.format(err)) |
| 612 | return |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 613 | |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 614 | try: |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 615 | check_call('mkdir -p %s' % mount_dir, shell=True) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 616 | except CalledProcessError as err: |
| 617 | pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 618 | call('rm -f %s' % fs_img, shell=True) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 619 | return |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 620 | |
| 621 | try: |
| 622 | # Mount the image so we can populate it. |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 623 | mount_fs(fs_type, fs_img, mount_dir) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 624 | except CalledProcessError as err: |
| 625 | pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) |
| 626 | call('rmdir %s' % mount_dir, shell=True) |
| 627 | call('rm -f %s' % fs_img, shell=True) |
| 628 | return |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 629 | |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 630 | try: |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 631 | # Create a subdirectory. |
| 632 | check_call('mkdir %s/SUBDIR' % mount_dir, shell=True) |
| 633 | |
| 634 | # Create a small file in this image. |
| 635 | check_call('dd if=/dev/urandom of=%s bs=1M count=1' |
| 636 | % small_file, shell=True) |
| 637 | |
| 638 | # Create a medium file in this image. |
| 639 | check_call('dd if=/dev/urandom of=%s bs=10M count=1' |
| 640 | % medium_file, shell=True) |
| 641 | |
| 642 | # Generate the md5sums of reads that we will test against small file |
| 643 | out = check_output( |
| 644 | 'dd if=%s bs=1M skip=0 count=1 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 645 | % small_file, shell=True).decode() |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 646 | md5val = [out.split()[0]] |
| 647 | out = check_output( |
| 648 | 'dd if=%s bs=10M skip=0 count=1 2> /dev/null | md5sum' |
Tom Rini | 784e27d | 2019-10-24 11:59:24 -0400 | [diff] [blame] | 649 | % medium_file, shell=True).decode() |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 650 | md5val.extend([out.split()[0]]) |
| 651 | |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 652 | except CalledProcessError: |
| 653 | pytest.skip('Setup failed for filesystem: ' + fs_type) |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 654 | umount_fs(mount_dir) |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 655 | return |
| 656 | else: |
Alper Nebi Yasak | 46132c2 | 2021-05-20 22:09:46 +0300 | [diff] [blame] | 657 | umount_fs(mount_dir) |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 658 | yield [fs_ubtype, fs_img, md5val] |
| 659 | finally: |
Jean-Jacques Hiblot | 8aea8a6 | 2019-02-13 12:15:27 +0100 | [diff] [blame] | 660 | call('rmdir %s' % mount_dir, shell=True) |
Andy Shevchenko | e70ed8c | 2021-02-11 16:40:12 +0200 | [diff] [blame] | 661 | call('rm -f %s' % fs_img, shell=True) |