1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2018, Linaro Limited
3 # Author: Takahiro Akashi <takahiro.akashi@linaro.org>
5 # U-Boot File System:mkdir Test
8 This test verifies mkdir operation on file system.
13 @pytest.mark.boardspec('sandbox')
14 class TestMkdir(object):
15 def test_mkdir1(self, u_boot_console, fs_obj_mkdir):
17 Test Case 1 - create a directory under a root
19 fs_type,fs_img = fs_obj_mkdir
20 with u_boot_console.log.section('Test Case 1 - mkdir'):
21 output = u_boot_console.run_command_list([
22 'host bind 0 %s' % fs_img,
23 '%smkdir host 0:0 dir1' % fs_type,
24 '%sls host 0:0 /' % fs_type])
25 assert('dir1/' in ''.join(output))
27 output = u_boot_console.run_command(
28 '%sls host 0:0 dir1' % fs_type)
29 assert('./' in output)
30 assert('../' in output)
32 def test_mkdir2(self, u_boot_console, fs_obj_mkdir):
34 Test Case 2 - create a directory under a sub-directory
36 fs_type,fs_img = fs_obj_mkdir
37 with u_boot_console.log.section('Test Case 2 - mkdir (sub-sub directory)'):
38 output = u_boot_console.run_command_list([
39 'host bind 0 %s' % fs_img,
40 '%smkdir host 0:0 dir1/dir2' % fs_type,
41 '%sls host 0:0 dir1' % fs_type])
42 assert('dir2/' in ''.join(output))
44 output = u_boot_console.run_command(
45 '%sls host 0:0 dir1/dir2' % fs_type)
46 assert('./' in output)
47 assert('../' in output)
49 def test_mkdir3(self, u_boot_console, fs_obj_mkdir):
51 Test Case 3 - trying to create a directory with a non-existing
54 fs_type,fs_img = fs_obj_mkdir
55 with u_boot_console.log.section('Test Case 3 - mkdir (non-existing path)'):
56 output = u_boot_console.run_command_list([
57 'host bind 0 %s' % fs_img,
58 '%smkdir host 0:0 none/dir3' % fs_type])
59 assert('Unable to create a directory' in ''.join(output))
61 def test_mkdir4(self, u_boot_console, fs_obj_mkdir):
63 Test Case 4 - trying to create "." should fail
65 fs_type,fs_img = fs_obj_mkdir
66 with u_boot_console.log.section('Test Case 4 - mkdir (".")'):
67 output = u_boot_console.run_command_list([
68 'host bind 0 %s' % fs_img,
69 '%smkdir host 0:0 .' % fs_type])
70 assert('Unable to create a directory' in ''.join(output))
72 def test_mkdir5(self, u_boot_console, fs_obj_mkdir):
74 Test Case 5 - trying to create ".." should fail
76 fs_type,fs_img = fs_obj_mkdir
77 with u_boot_console.log.section('Test Case 5 - mkdir ("..")'):
78 output = u_boot_console.run_command_list([
79 'host bind 0 %s' % fs_img,
80 '%smkdir host 0:0 ..' % fs_type])
81 assert('Unable to create a directory' in ''.join(output))
83 def test_mkdir6(self, u_boot_console, fs_obj_mkdir):
85 'Test Case 6 - create as many directories as amount of directory
86 entries goes beyond a cluster size)'
88 fs_type,fs_img = fs_obj_mkdir
89 with u_boot_console.log.section('Test Case 6 - mkdir (create many)'):
90 output = u_boot_console.run_command_list([
91 'host bind 0 %s' % fs_img,
92 '%smkdir host 0:0 dir6' % fs_type,
93 '%sls host 0:0 /' % fs_type])
94 assert('dir6/' in ''.join(output))
96 for i in range(0, 20):
97 output = u_boot_console.run_command(
98 '%smkdir host 0:0 dir6/0123456789abcdef%02x'
100 output = u_boot_console.run_command('%sls host 0:0 dir6' % fs_type)
101 assert('0123456789abcdef00/' in output)
102 assert('0123456789abcdef13/' in output)
104 output = u_boot_console.run_command(
105 '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_type)
106 assert('./' in output)
107 assert('../' in output)
109 output = u_boot_console.run_command(
110 '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_type)
111 assert('0123456789abcdef00/' in output)
112 assert('0123456789abcdef13/' in output)