@@ -25,10 +25,33 @@ def listdir(self, dir):
2525 return ['a%d' % self .id ]
2626 def chdir (self , dir ):
2727 print (self .id , 'chdir' , dir )
28+ def getcwd (self ):
29+ print (self .id , 'getcwd' )
30+ return 'dir%d' % self .id
31+ def mkdir (self , path ):
32+ print (self .id , 'mkdir' , path )
33+ def remove (self , path ):
34+ print (self .id , 'remove' , path )
35+ def rename (self , old_path , new_path ):
36+ print (self .id , 'rename' , old_path , new_path )
37+ def rmdir (self , path ):
38+ print (self .id , 'rmdir' , path )
39+ def stat (self , path ):
40+ print (self .id , 'stat' , path )
41+ return (self .id ,)
42+ def statvfs (self , path ):
43+ print (self .id , 'statvfs' , path )
44+ return (self .id ,)
2845 def open (self , file , mode ):
2946 print (self .id , 'open' , file , mode )
3047
3148
49+ # stat root dir
50+ print (uos .stat ('/' ))
51+
52+ # getcwd when in root dir
53+ print (uos .getcwd ())
54+
3255# basic mounting and listdir
3356uos .mount (Filesystem (1 ), '/test_mnt' )
3457print (uos .listdir ())
@@ -42,14 +65,43 @@ def open(self, file, mode):
4265print (uos .listdir ())
4366print (uos .listdir ('/test_mnt2' ))
4467
45- # chdir
68+ # mounting over an existing mount point
69+ try :
70+ uos .mount (Filesystem (3 ), '/test_mnt2' )
71+ except OSError :
72+ print ('OSError' )
73+
74+ # mkdir of a mount point
75+ try :
76+ uos .mkdir ('/test_mnt' )
77+ except OSError :
78+ print ('OSError' )
79+
80+ # rename across a filesystem
81+ try :
82+ uos .rename ('/test_mnt/a' , '/test_mnt2/b' )
83+ except OSError :
84+ print ('OSError' )
85+
86+ # delegating to mounted filesystem
4687uos .chdir ('test_mnt' )
4788print (uos .listdir ())
48-
49- # open
89+ print (uos .getcwd ())
90+ uos .mkdir ('test_dir' )
91+ uos .remove ('test_file' )
92+ uos .rename ('test_file' , 'test_file2' )
93+ uos .rmdir ('test_dir' )
94+ print (uos .stat ('test_file' ))
95+ print (uos .statvfs ('/test_mnt' ))
5096open ('test_file' )
5197open ('test_file' , 'wb' )
5298
5399# umount
54100uos .umount ('/test_mnt' )
55101uos .umount ('/test_mnt2' )
102+
103+ # umount a non-existent mount point
104+ try :
105+ uos .umount ('/test_mnt' )
106+ except OSError :
107+ print ('OSError' )
0 commit comments