@@ -61,7 +61,7 @@ pub fn test() {
6161 assert_eq ! ( status, Status :: SUCCESS ) ;
6262 assert ! ( shell. get_env( Some ( test_var) ) . is_none( ) ) ;
6363
64- /* Test setting and getting current file system and directory */
64+ /* Test setting and getting current file system and current directory */
6565 let mut fs_buf = [ 0u16 ; 16 ] ;
6666 let fs_var = CStr16 :: from_str_with_buf ( "fs0:" , & mut fs_buf) . unwrap ( ) ;
6767 let mut dir_buf = [ 0u16 ; 32 ] ;
@@ -75,6 +75,7 @@ pub fn test() {
7575 let expected_fs_str = CStr16 :: from_str_with_buf ( "FS0:\\ " , & mut test_buf) . unwrap ( ) ;
7676 assert_eq ! ( cur_fs_str, expected_fs_str) ;
7777
78+ // Changing current file system
7879 let fs_var = CStr16 :: from_str_with_buf ( "fs1:" , & mut fs_buf) . unwrap ( ) ;
7980 let dir_var = CStr16 :: from_str_with_buf ( "/" , & mut dir_buf) . unwrap ( ) ;
8081 let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
@@ -87,6 +88,7 @@ pub fn test() {
8788 let expected_fs_str = CStr16 :: from_str_with_buf ( "FS1:\\ " , & mut test_buf) . unwrap ( ) ;
8889 assert_eq ! ( cur_fs_str, expected_fs_str) ;
8990
91+ // Changing current file system and current directory
9092 let fs_var = CStr16 :: from_str_with_buf ( "fs0:" , & mut fs_buf) . unwrap ( ) ;
9193 let dir_var = CStr16 :: from_str_with_buf ( "efi/" , & mut dir_buf) . unwrap ( ) ;
9294 let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
@@ -99,7 +101,13 @@ pub fn test() {
99101 let expected_fs_str = CStr16 :: from_str_with_buf ( "FS0:\\ efi" , & mut test_buf) . unwrap ( ) ;
100102 assert_eq ! ( cur_fs_str, expected_fs_str) ;
101103
102- /* Test NULL file system cases */
104+ /* Test current working directory cases */
105+
106+ // At this point, the current working file system has not been set
107+ // So we expect a NULL output
108+ assert ! ( shell. get_cur_dir( None ) . is_none( ) ) ;
109+
110+ // Setting the current working file system and current working directory
103111 let dir_var = CStr16 :: from_str_with_buf ( "fs0:/" , & mut dir_buf) . unwrap ( ) ;
104112 let status = shell. set_cur_dir ( None , Some ( dir_var) ) ;
105113 assert_eq ! ( status, Status :: SUCCESS ) ;
@@ -114,6 +122,7 @@ pub fn test() {
114122 . expect ( "Could not get the current file system mapping" ) ;
115123 assert_eq ! ( cur_fs_str, expected_fs_str) ;
116124
125+ // Changing current working directory
117126 let dir_var = CStr16 :: from_str_with_buf ( "/efi" , & mut dir_buf) . unwrap ( ) ;
118127 let status = shell. set_cur_dir ( None , Some ( dir_var) ) ;
119128 assert_eq ! ( status, Status :: SUCCESS ) ;
@@ -122,6 +131,26 @@ pub fn test() {
122131 . expect ( "Could not get the current file system mapping" ) ;
123132 let expected_fs_str = CStr16 :: from_str_with_buf ( "FS0:\\ efi" , & mut test_buf) . unwrap ( ) ;
124133 assert_eq ! ( cur_fs_str, expected_fs_str) ;
134+ let cur_fs_str = shell
135+ . get_cur_dir ( None )
136+ . expect ( "Could not get the current file system mapping" ) ;
137+ assert_eq ! ( cur_fs_str, expected_fs_str) ;
138+
139+ // Changing current directory in a non-current working file system
140+ let fs_var = CStr16 :: from_str_with_buf ( "fs0:" , & mut fs_buf) . unwrap ( ) ;
141+ let dir_var = CStr16 :: from_str_with_buf ( "efi/tools" , & mut dir_buf) . unwrap ( ) ;
142+ let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
143+ assert_eq ! ( status, Status :: SUCCESS ) ;
144+ let cur_fs_str = shell
145+ . get_cur_dir ( None )
146+ . expect ( "Could not get the current file system mapping" ) ;
147+ assert_ne ! ( cur_fs_str, expected_fs_str) ;
148+
149+ let expected_fs_str = CStr16 :: from_str_with_buf ( "FS0:\\ efi\\ tools" , & mut test_buf) . unwrap ( ) ;
150+ let cur_fs_str = shell
151+ . get_cur_dir ( Some ( fs_var) )
152+ . expect ( "Could not get the current file system mapping" ) ;
153+ assert_eq ! ( cur_fs_str, expected_fs_str) ;
125154
126155 // Create a file
127156 // let status = shell.create_file(test_str, 0).expect("Could not create file");
0 commit comments