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')
15 class TestMkdir(object):
16 def test_mkdir1(self, u_boot_console, fs_obj_mkdir):
18 Test Case 1 - create a directory under a root
20 fs_type,fs_img = fs_obj_mkdir
21 with u_boot_console.log.section('Test Case 1 - mkdir'):
22 output = u_boot_console.run_command_list([
23 'host bind 0 %s' % fs_img,
24 '%smkdir host 0:0 dir1' % fs_type,
25 '%sls host 0:0 /' % fs_type])
26 assert('dir1/' in ''.join(output))
28 output = u_boot_console.run_command(
29 '%sls host 0:0 dir1' % fs_type)
30 assert('./' in output)
31 assert('../' in output)
33 def test_mkdir2(self, u_boot_console, fs_obj_mkdir):
35 Test Case 2 - create a directory under a sub-directory
37 fs_type,fs_img = fs_obj_mkdir
38 with u_boot_console.log.section('Test Case 2 - mkdir (sub-sub directory)'):
39 output = u_boot_console.run_command_list([
40 'host bind 0 %s' % fs_img,
41 '%smkdir host 0:0 dir1/dir2' % fs_type,
42 '%sls host 0:0 dir1' % fs_type])
43 assert('dir2/' in ''.join(output))
45 output = u_boot_console.run_command(
46 '%sls host 0:0 dir1/dir2' % fs_type)
47 assert('./' in output)
48 assert('../' in output)
50 def test_mkdir3(self, u_boot_console, fs_obj_mkdir):
52 Test Case 3 - trying to create a directory with a non-existing
55 fs_type,fs_img = fs_obj_mkdir
56 with u_boot_console.log.section('Test Case 3 - mkdir (non-existing path)'):
57 output = u_boot_console.run_command_list([
58 'host bind 0 %s' % fs_img,
59 '%smkdir host 0:0 none/dir3' % fs_type])
60 assert('Unable to create a directory' in ''.join(output))
62 def test_mkdir4(self, u_boot_console, fs_obj_mkdir):
64 Test Case 4 - trying to create "." should fail
66 fs_type,fs_img = fs_obj_mkdir
67 with u_boot_console.log.section('Test Case 4 - mkdir (".")'):
68 output = u_boot_console.run_command_list([
69 'host bind 0 %s' % fs_img,
70 '%smkdir host 0:0 .' % fs_type])
71 assert('Unable to create a directory' in ''.join(output))
73 def test_mkdir5(self, u_boot_console, fs_obj_mkdir):
75 Test Case 5 - trying to create ".." should fail
77 fs_type,fs_img = fs_obj_mkdir
78 with u_boot_console.log.section('Test Case 5 - mkdir ("..")'):
79 output = u_boot_console.run_command_list([
80 'host bind 0 %s' % fs_img,
81 '%smkdir host 0:0 ..' % fs_type])
82 assert('Unable to create a directory' in ''.join(output))
84 def test_mkdir6(self, u_boot_console, fs_obj_mkdir):
86 'Test Case 6 - create as many directories as amount of directory
87 entries goes beyond a cluster size)'
89 fs_type,fs_img = fs_obj_mkdir
90 with u_boot_console.log.section('Test Case 6 - mkdir (create many)'):
91 output = u_boot_console.run_command_list([
92 'host bind 0 %s' % fs_img,
93 '%smkdir host 0:0 dir6' % fs_type,
94 '%sls host 0:0 /' % fs_type])
95 assert('dir6/' in ''.join(output))
97 for i in range(0, 20):
98 output = u_boot_console.run_command(
99 '%smkdir host 0:0 dir6/0123456789abcdef%02x'
101 output = u_boot_console.run_command('%sls host 0:0 dir6' % fs_type)
102 assert('0123456789abcdef00/' in output)
103 assert('0123456789abcdef13/' in output)
105 output = u_boot_console.run_command(
106 '%sls host 0:0 dir6/0123456789abcdef13/.' % fs_type)
107 assert('./' in output)
108 assert('../' in output)
110 output = u_boot_console.run_command(
111 '%sls host 0:0 dir6/0123456789abcdef13/..' % fs_type)
112 assert('0123456789abcdef00/' in output)
113 assert('0123456789abcdef13/' in output)