@@ -61,7 +61,7 @@ pub fn test() {
61
61
assert_eq ! ( status, Status :: SUCCESS ) ;
62
62
assert ! ( shell. get_env( Some ( test_var) ) . is_none( ) ) ;
63
63
64
- /* Test setting and getting current file system and directory */
64
+ /* Test setting and getting current file system and current directory */
65
65
let mut fs_buf = [ 0u16 ; 16 ] ;
66
66
let fs_var = CStr16 :: from_str_with_buf ( "fs0:" , & mut fs_buf) . unwrap ( ) ;
67
67
let mut dir_buf = [ 0u16 ; 32 ] ;
@@ -75,6 +75,7 @@ pub fn test() {
75
75
let expected_fs_str = CStr16 :: from_str_with_buf ( "FS0:\\ " , & mut test_buf) . unwrap ( ) ;
76
76
assert_eq ! ( cur_fs_str, expected_fs_str) ;
77
77
78
+ // Changing current file system
78
79
let fs_var = CStr16 :: from_str_with_buf ( "fs1:" , & mut fs_buf) . unwrap ( ) ;
79
80
let dir_var = CStr16 :: from_str_with_buf ( "/" , & mut dir_buf) . unwrap ( ) ;
80
81
let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
@@ -87,6 +88,7 @@ pub fn test() {
87
88
let expected_fs_str = CStr16 :: from_str_with_buf ( "FS1:\\ " , & mut test_buf) . unwrap ( ) ;
88
89
assert_eq ! ( cur_fs_str, expected_fs_str) ;
89
90
91
+ // Changing current file system and current directory
90
92
let fs_var = CStr16 :: from_str_with_buf ( "fs0:" , & mut fs_buf) . unwrap ( ) ;
91
93
let dir_var = CStr16 :: from_str_with_buf ( "efi/" , & mut dir_buf) . unwrap ( ) ;
92
94
let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
@@ -99,7 +101,13 @@ pub fn test() {
99
101
let expected_fs_str = CStr16 :: from_str_with_buf ( "FS0:\\ efi" , & mut test_buf) . unwrap ( ) ;
100
102
assert_eq ! ( cur_fs_str, expected_fs_str) ;
101
103
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
103
111
let dir_var = CStr16 :: from_str_with_buf ( "fs0:/" , & mut dir_buf) . unwrap ( ) ;
104
112
let status = shell. set_cur_dir ( None , Some ( dir_var) ) ;
105
113
assert_eq ! ( status, Status :: SUCCESS ) ;
@@ -114,6 +122,7 @@ pub fn test() {
114
122
. expect ( "Could not get the current file system mapping" ) ;
115
123
assert_eq ! ( cur_fs_str, expected_fs_str) ;
116
124
125
+ // Changing current working directory
117
126
let dir_var = CStr16 :: from_str_with_buf ( "/efi" , & mut dir_buf) . unwrap ( ) ;
118
127
let status = shell. set_cur_dir ( None , Some ( dir_var) ) ;
119
128
assert_eq ! ( status, Status :: SUCCESS ) ;
@@ -122,6 +131,26 @@ pub fn test() {
122
131
. expect ( "Could not get the current file system mapping" ) ;
123
132
let expected_fs_str = CStr16 :: from_str_with_buf ( "FS0:\\ efi" , & mut test_buf) . unwrap ( ) ;
124
133
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) ;
125
154
126
155
// Create a file
127
156
// let status = shell.create_file(test_str, 0).expect("Could not create file");
0 commit comments