blob: 9c213f2da55cc0396d407413fe627db90341eadb [file] [log] [blame]
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +09001# SPDX-License-Identifier: GPL-2.0+
2# Copyright (c) 2018, Linaro Limited
3# Author: Takahiro Akashi <takahiro.akashi@linaro.org>
4#
5# U-Boot File System:Exntented Test
6
7"""
8This test verifies extended write operation on file system.
9"""
10
Stefan Herbrechtsmeiera09bcfe2023-03-22 09:46:02 +010011import os.path
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090012import pytest
13import re
Stefan Herbrechtsmeiera09bcfe2023-03-22 09:46:02 +010014from subprocess import check_output
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090015from fstest_defs import *
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +010016from fstest_helpers import assert_fs_integrity
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090017
Stefan Herbrechtsmeiera09bcfe2023-03-22 09:46:02 +010018PLAIN_FILE='abcdefgh.txt'
19MANGLE_FILE='abcdefghi.txt'
20
21def str2fat(long_filename):
22 splitext = os.path.splitext(long_filename.upper())
23 name = splitext[0]
24 ext = splitext[1][1:]
25 if len(name) > 8:
26 name = '%s~1' % name[:6]
27 return '%-8s %s' % (name, ext)
28
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090029@pytest.mark.boardspec('sandbox')
Simon Glass3fcb8282018-11-18 08:14:29 -070030@pytest.mark.slow
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090031class TestFsExt(object):
Simon Glassddba5202025-02-09 09:07:14 -070032 def test_fs_ext1(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090033 """
34 Test Case 1 - write a file with absolute path
35 """
36 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -070037 with ubman.log.section('Test Case 1 - write with abs path'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090038 # Test Case 1a - Check if command successfully returned
Simon Glassddba5202025-02-09 09:07:14 -070039 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090040 '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)])
44 assert('20480 bytes written' in ''.join(output))
45
46 # Test Case 1b - Check md5 of file content
Simon Glassddba5202025-02-09 09:07:14 -070047 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090048 'mw.b %x 00 100' % ADDR,
49 '%sload host 0:0 %x /dir1/%s.w1' % (fs_type, ADDR, MIN_FILE),
50 'md5sum %x $filesize' % ADDR,
51 'setenv filesize'])
52 assert(md5val[0] in ''.join(output))
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +010053 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090054
Simon Glassddba5202025-02-09 09:07:14 -070055 def test_fs_ext2(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090056 """
57 Test Case 2 - write to a file with relative path
58 """
59 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -070060 with ubman.log.section('Test Case 2 - write with rel path'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090061 # Test Case 2a - Check if command successfully returned
Simon Glassddba5202025-02-09 09:07:14 -070062 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090063 '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)])
67 assert('20480 bytes written' in ''.join(output))
68
69 # Test Case 2b - Check md5 of file content
Simon Glassddba5202025-02-09 09:07:14 -070070 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090071 'mw.b %x 00 100' % ADDR,
72 '%sload host 0:0 %x dir1/%s.w2' % (fs_type, ADDR, MIN_FILE),
73 'md5sum %x $filesize' % ADDR,
74 'setenv filesize'])
75 assert(md5val[0] in ''.join(output))
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +010076 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090077
Simon Glassddba5202025-02-09 09:07:14 -070078 def test_fs_ext3(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090079 """
80 Test Case 3 - write to a file with invalid path
81 """
82 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -070083 with ubman.log.section('Test Case 3 - write with invalid path'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090084 # Test Case 3 - Check if command expectedly failed
Simon Glassddba5202025-02-09 09:07:14 -070085 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090086 '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)])
Lad Prabhakarfad2e882020-10-20 08:45:46 +010090 assert('Unable to write file /dir1/none/' in ''.join(output))
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +010091 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090092
Simon Glassddba5202025-02-09 09:07:14 -070093 def test_fs_ext4(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090094 """
95 Test Case 4 - write at non-zero offset, enlarging file size
96 """
97 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -070098 with ubman.log.section('Test Case 4 - write at non-zero offset, enlarging file size'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +090099 # Test Case 4a - Check if command successfully returned
Simon Glassddba5202025-02-09 09:07:14 -0700100 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900101 '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)])
Simon Glassddba5202025-02-09 09:07:14 -0700105 output = ubman.run_command(
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900106 '%swrite host 0:0 %x /dir1/%s.w4 $filesize 0x1400'
107 % (fs_type, ADDR, MIN_FILE))
108 assert('20480 bytes written' in output)
109
110 # Test Case 4b - Check size of written file
Simon Glassddba5202025-02-09 09:07:14 -0700111 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900112 '%ssize host 0:0 /dir1/%s.w4' % (fs_type, MIN_FILE),
113 'printenv filesize',
114 'setenv filesize'])
115 assert('filesize=6400' in ''.join(output))
116
117 # Test Case 4c - Check md5 of file content
Simon Glassddba5202025-02-09 09:07:14 -0700118 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900119 'mw.b %x 00 100' % ADDR,
120 '%sload host 0:0 %x /dir1/%s.w4' % (fs_type, ADDR, MIN_FILE),
121 'md5sum %x $filesize' % ADDR,
122 'setenv filesize'])
123 assert(md5val[1] in ''.join(output))
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +0100124 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900125
Simon Glassddba5202025-02-09 09:07:14 -0700126 def test_fs_ext5(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900127 """
128 Test Case 5 - write at non-zero offset, shrinking file size
129 """
130 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -0700131 with ubman.log.section('Test Case 5 - write at non-zero offset, shrinking file size'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900132 # Test Case 5a - Check if command successfully returned
Simon Glassddba5202025-02-09 09:07:14 -0700133 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900134 '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)])
Simon Glassddba5202025-02-09 09:07:14 -0700138 output = ubman.run_command(
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900139 '%swrite host 0:0 %x /dir1/%s.w5 0x1400 0x1400'
140 % (fs_type, ADDR, MIN_FILE))
141 assert('5120 bytes written' in output)
142
143 # Test Case 5b - Check size of written file
Simon Glassddba5202025-02-09 09:07:14 -0700144 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900145 '%ssize host 0:0 /dir1/%s.w5' % (fs_type, MIN_FILE),
146 'printenv filesize',
147 'setenv filesize'])
148 assert('filesize=2800' in ''.join(output))
149
150 # Test Case 5c - Check md5 of file content
Simon Glassddba5202025-02-09 09:07:14 -0700151 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900152 'mw.b %x 00 100' % ADDR,
153 '%sload host 0:0 %x /dir1/%s.w5' % (fs_type, ADDR, MIN_FILE),
154 'md5sum %x $filesize' % ADDR,
155 'setenv filesize'])
156 assert(md5val[2] in ''.join(output))
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +0100157 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900158
Simon Glassddba5202025-02-09 09:07:14 -0700159 def test_fs_ext6(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900160 """
161 Test Case 6 - write nothing at the start, truncating to zero
162 """
163 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -0700164 with ubman.log.section('Test Case 6 - write nothing at the start, truncating to zero'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900165 # Test Case 6a - Check if command successfully returned
Simon Glassddba5202025-02-09 09:07:14 -0700166 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900167 '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)])
Simon Glassddba5202025-02-09 09:07:14 -0700171 output = ubman.run_command(
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900172 '%swrite host 0:0 %x /dir1/%s.w6 0 0'
173 % (fs_type, ADDR, MIN_FILE))
174 assert('0 bytes written' in output)
175
176 # Test Case 6b - Check size of written file
Simon Glassddba5202025-02-09 09:07:14 -0700177 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900178 '%ssize host 0:0 /dir1/%s.w6' % (fs_type, MIN_FILE),
179 'printenv filesize',
180 'setenv filesize'])
181 assert('filesize=0' in ''.join(output))
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +0100182 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900183
Simon Glassddba5202025-02-09 09:07:14 -0700184 def test_fs_ext7(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900185 """
186 Test Case 7 - write at the end (append)
187 """
188 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -0700189 with ubman.log.section('Test Case 7 - write at the end (append)'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900190 # Test Case 7a - Check if command successfully returned
Simon Glassddba5202025-02-09 09:07:14 -0700191 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900192 '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)])
Simon Glassddba5202025-02-09 09:07:14 -0700196 output = ubman.run_command(
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900197 '%swrite host 0:0 %x /dir1/%s.w7 $filesize $filesize'
198 % (fs_type, ADDR, MIN_FILE))
199 assert('20480 bytes written' in output)
200
201 # Test Case 7b - Check size of written file
Simon Glassddba5202025-02-09 09:07:14 -0700202 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900203 '%ssize host 0:0 /dir1/%s.w7' % (fs_type, MIN_FILE),
204 'printenv filesize',
205 'setenv filesize'])
206 assert('filesize=a000' in ''.join(output))
207
208 # Test Case 7c - Check md5 of file content
Simon Glassddba5202025-02-09 09:07:14 -0700209 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900210 'mw.b %x 00 100' % ADDR,
211 '%sload host 0:0 %x /dir1/%s.w7' % (fs_type, ADDR, MIN_FILE),
212 'md5sum %x $filesize' % ADDR,
213 'setenv filesize'])
214 assert(md5val[3] in ''.join(output))
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +0100215 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900216
Simon Glassddba5202025-02-09 09:07:14 -0700217 def test_fs_ext8(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900218 """
219 Test Case 8 - write at offset beyond the end of file
220 """
221 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -0700222 with ubman.log.section('Test Case 8 - write beyond the end'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900223 # Test Case 8a - Check if command expectedly failed
Simon Glassddba5202025-02-09 09:07:14 -0700224 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900225 '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)])
Simon Glassddba5202025-02-09 09:07:14 -0700229 output = ubman.run_command(
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900230 '%swrite host 0:0 %x /dir1/%s.w8 0x1400 %x'
231 % (fs_type, ADDR, MIN_FILE, 0x100000 + 0x1400))
Lad Prabhakarfad2e882020-10-20 08:45:46 +0100232 assert('Unable to write file /dir1' in output)
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +0100233 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900234
Simon Glassddba5202025-02-09 09:07:14 -0700235 def test_fs_ext9(self, ubman, fs_obj_ext):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900236 """
237 Test Case 9 - write to a non-existing file at non-zero offset
238 """
239 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -0700240 with ubman.log.section('Test Case 9 - write to non-existing file with non-zero offset'):
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900241 # Test Case 9a - Check if command expectedly failed
Simon Glassddba5202025-02-09 09:07:14 -0700242 output = ubman.run_command_list([
AKASHI Takahirodde5d3f2018-09-11 15:59:20 +0900243 '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)])
Lad Prabhakarfad2e882020-10-20 08:45:46 +0100247 assert('Unable to write file /dir1' in ''.join(output))
Jean-Jacques Hiblotd2fd35c2019-02-13 12:15:23 +0100248 assert_fs_integrity(fs_type, fs_img)
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900249
Simon Glassddba5202025-02-09 09:07:14 -0700250 def test_fs_ext10(self, ubman, fs_obj_ext):
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900251 """
252 'Test Case 10 - create/delete as many directories under root directory
253 as amount of directory entries goes beyond one cluster size)'
254 """
255 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -0700256 with ubman.log.section('Test Case 10 - create/delete (many)'):
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900257 # Test Case 10a - Create many files
258 # Please note that the size of directory entry is 32 bytes.
259 # So one typical cluster may holds 64 (2048/32) entries.
Simon Glassddba5202025-02-09 09:07:14 -0700260 output = ubman.run_command(
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900261 'host bind 0 %s' % fs_img)
262
263 for i in range(0, 66):
Simon Glassddba5202025-02-09 09:07:14 -0700264 output = ubman.run_command(
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900265 '%swrite host 0:0 %x /FILE0123456789_%02x 100'
266 % (fs_type, ADDR, i))
Simon Glassddba5202025-02-09 09:07:14 -0700267 output = ubman.run_command('%sls host 0:0 /' % fs_type)
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900268 assert('FILE0123456789_00' in output)
269 assert('FILE0123456789_41' in output)
270
271 # Test Case 10b - Delete many files
272 for i in range(0, 66):
Simon Glassddba5202025-02-09 09:07:14 -0700273 output = ubman.run_command(
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900274 '%srm host 0:0 /FILE0123456789_%02x'
275 % (fs_type, i))
Simon Glassddba5202025-02-09 09:07:14 -0700276 output = ubman.run_command('%sls host 0:0 /' % fs_type)
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900277 assert(not 'FILE0123456789_00' in output)
278 assert(not 'FILE0123456789_41' in output)
279
280 # Test Case 10c - Create many files again
281 # Please note no.64 and 65 are intentionally re-created
282 for i in range(64, 128):
Simon Glassddba5202025-02-09 09:07:14 -0700283 output = ubman.run_command(
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900284 '%swrite host 0:0 %x /FILE0123456789_%02x 100'
285 % (fs_type, ADDR, i))
Simon Glassddba5202025-02-09 09:07:14 -0700286 output = ubman.run_command('%sls host 0:0 /' % fs_type)
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900287 assert('FILE0123456789_40' in output)
288 assert('FILE0123456789_79' in output)
289
290 assert_fs_integrity(fs_type, fs_img)
291
Simon Glassddba5202025-02-09 09:07:14 -0700292 def test_fs_ext11(self, ubman, fs_obj_ext):
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900293 """
294 'Test Case 11 - create/delete as many directories under non-root
295 directory as amount of directory entries goes beyond one cluster size)'
296 """
297 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -0700298 with ubman.log.section('Test Case 11 - create/delete (many)'):
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900299 # Test Case 11a - Create many files
300 # Please note that the size of directory entry is 32 bytes.
301 # So one typical cluster may holds 64 (2048/32) entries.
Simon Glassddba5202025-02-09 09:07:14 -0700302 output = ubman.run_command(
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900303 'host bind 0 %s' % fs_img)
304
305 for i in range(0, 66):
Simon Glassddba5202025-02-09 09:07:14 -0700306 output = ubman.run_command(
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900307 '%swrite host 0:0 %x /dir1/FILE0123456789_%02x 100'
308 % (fs_type, ADDR, i))
Simon Glassddba5202025-02-09 09:07:14 -0700309 output = ubman.run_command('%sls host 0:0 /dir1' % fs_type)
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900310 assert('FILE0123456789_00' in output)
311 assert('FILE0123456789_41' in output)
312
313 # Test Case 11b - Delete many files
314 for i in range(0, 66):
Simon Glassddba5202025-02-09 09:07:14 -0700315 output = ubman.run_command(
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900316 '%srm host 0:0 /dir1/FILE0123456789_%02x'
317 % (fs_type, i))
Simon Glassddba5202025-02-09 09:07:14 -0700318 output = ubman.run_command('%sls host 0:0 /dir1' % fs_type)
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900319 assert(not 'FILE0123456789_00' in output)
320 assert(not 'FILE0123456789_41' in output)
321
322 # Test Case 11c - Create many files again
323 # Please note no.64 and 65 are intentionally re-created
324 for i in range(64, 128):
Simon Glassddba5202025-02-09 09:07:14 -0700325 output = ubman.run_command(
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900326 '%swrite host 0:0 %x /dir1/FILE0123456789_%02x 100'
327 % (fs_type, ADDR, i))
Simon Glassddba5202025-02-09 09:07:14 -0700328 output = ubman.run_command('%sls host 0:0 /dir1' % fs_type)
AKASHI Takahiro4b63f692019-11-26 17:28:49 +0900329 assert('FILE0123456789_40' in output)
330 assert('FILE0123456789_79' in output)
331
332 assert_fs_integrity(fs_type, fs_img)
Stefan Herbrechtsmeiera09bcfe2023-03-22 09:46:02 +0100333
Simon Glassddba5202025-02-09 09:07:14 -0700334 def test_fs_ext12(self, ubman, fs_obj_ext):
Stefan Herbrechtsmeiera09bcfe2023-03-22 09:46:02 +0100335 """
336 Test Case 12 - write plain and mangle file
337 """
338 fs_type,fs_img,md5val = fs_obj_ext
Simon Glassddba5202025-02-09 09:07:14 -0700339 with ubman.log.section('Test Case 12 - write plain and mangle file'):
Stefan Herbrechtsmeiera09bcfe2023-03-22 09:46:02 +0100340 # Test Case 12a - Check if command successfully returned
Simon Glassddba5202025-02-09 09:07:14 -0700341 output = ubman.run_command_list([
Stefan Herbrechtsmeiera09bcfe2023-03-22 09:46:02 +0100342 '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)])
347 assert('0 bytes written' in ''.join(output))
348 # Test Case 12b - Read file system content
349 output = check_output('mdir -i %s' % fs_img, shell=True).decode()
350 # Test Case 12c - Check if short filename is not mangled
351 assert(str2fat(PLAIN_FILE) in ''.join(output))
352 # Test Case 12d - Check if long filename is mangled
353 assert(str2fat(MANGLE_FILE) in ''.join(output))
354
355 assert_fs_integrity(fs_type, fs_img)