33use uefi:: boot:: ScopedProtocol ;
44use uefi:: proto:: shell:: Shell ;
55use uefi:: { boot, cstr16} ;
6- use uefi_raw:: Status ;
76
8- /// Test `get_env ()`, `get_envs ()`, and `set_env ()`
7+ /// Test `var ()`, `vars ()`, and `set_var ()`
98pub fn test_env ( shell : & ScopedProtocol < Shell > ) {
109 /* Test retrieving list of environment variable names */
11- let mut cur_env_vec = shell. get_envs ( ) ;
10+ let mut cur_env_vec = shell. vars ( ) ;
1211 assert_eq ! ( cur_env_vec. next( ) . unwrap( ) , cstr16!( "path" ) , ) ;
1312 // check pre-defined shell variables; see UEFI Shell spec
1413 assert_eq ! ( cur_env_vec. next( ) . unwrap( ) , cstr16!( "nonesting" ) , ) ;
15- let cur_env_vec = shell. get_envs ( ) ;
14+ let cur_env_vec = shell. vars ( ) ;
1615 let default_len = cur_env_vec. count ( ) ;
1716
1817 /* Test setting and getting a specific environment variable */
19- let cur_env_vec = shell. get_envs ( ) ;
18+ let cur_env_vec = shell. vars ( ) ;
2019 let test_var = cstr16 ! ( "test_var" ) ;
2120 let test_val = cstr16 ! ( "test_val" ) ;
22- assert ! ( shell. get_env ( test_var) . is_none( ) ) ;
23- let status = shell. set_env ( test_var, test_val, false ) ;
24- assert_eq ! ( status, Status :: SUCCESS ) ;
21+ assert ! ( shell. var ( test_var) . is_none( ) ) ;
22+ let status = shell. set_var ( test_var, test_val, false ) ;
23+ assert ! ( status. is_ok ( ) ) ;
2524 let cur_env_str = shell
26- . get_env ( test_var)
25+ . var ( test_var)
2726 . expect ( "Could not get environment variable" ) ;
2827 assert_eq ! ( cur_env_str, test_val) ;
2928
@@ -34,7 +33,7 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
3433 }
3534 }
3635 assert ! ( !found_var) ;
37- let cur_env_vec = shell. get_envs ( ) ;
36+ let cur_env_vec = shell. vars ( ) ;
3837 let mut found_var = false ;
3938 for env_var in cur_env_vec {
4039 if env_var == test_var {
@@ -43,49 +42,49 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
4342 }
4443 assert ! ( found_var) ;
4544
46- let cur_env_vec = shell. get_envs ( ) ;
45+ let cur_env_vec = shell. vars ( ) ;
4746 assert_eq ! ( cur_env_vec. count( ) , default_len + 1 ) ;
4847
4948 /* Test deleting environment variable */
5049 let test_val = cstr16 ! ( "" ) ;
51- let status = shell. set_env ( test_var, test_val, false ) ;
52- assert_eq ! ( status, Status :: SUCCESS ) ;
53- assert ! ( shell. get_env ( test_var) . is_none( ) ) ;
50+ let status = shell. set_var ( test_var, test_val, false ) ;
51+ assert ! ( status. is_ok ( ) ) ;
52+ assert ! ( shell. var ( test_var) . is_none( ) ) ;
5453
55- let cur_env_vec = shell. get_envs ( ) ;
54+ let cur_env_vec = shell. vars ( ) ;
5655 let mut found_var = false ;
5756 for env_var in cur_env_vec {
5857 if env_var == test_var {
5958 found_var = true ;
6059 }
6160 }
6261 assert ! ( !found_var) ;
63- let cur_env_vec = shell. get_envs ( ) ;
62+ let cur_env_vec = shell. vars ( ) ;
6463 assert_eq ! ( cur_env_vec. count( ) , default_len) ;
6564}
6665
67- /// Test `get_cur_dir ()` and `set_cur_dir ()`
66+ /// Test `current_dir ()` and `set_current_dir ()`
6867pub fn test_cur_dir ( shell : & ScopedProtocol < Shell > ) {
6968 /* Test setting and getting current file system and current directory */
7069 let fs_var = cstr16 ! ( "fs0:" ) ;
7170 let dir_var = cstr16 ! ( "/" ) ;
72- let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
73- assert_eq ! ( status, Status :: SUCCESS ) ;
71+ let status = shell. set_current_dir ( Some ( fs_var) , Some ( dir_var) ) ;
72+ assert ! ( status. is_ok ( ) ) ;
7473
7574 let cur_fs_str = shell
76- . get_cur_dir ( Some ( fs_var) )
75+ . current_dir ( Some ( fs_var) )
7776 . expect ( "Could not get the current file system mapping" ) ;
7877 let expected_fs_str = cstr16 ! ( "FS0:\\ " ) ;
7978 assert_eq ! ( cur_fs_str, expected_fs_str) ;
8079
8180 // Changing current file system
8281 let fs_var = cstr16 ! ( "fs1:" ) ;
8382 let dir_var = cstr16 ! ( "/" ) ;
84- let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
85- assert_eq ! ( status, Status :: SUCCESS ) ;
83+ let status = shell. set_current_dir ( Some ( fs_var) , Some ( dir_var) ) ;
84+ assert ! ( status. is_ok ( ) ) ;
8685
8786 let cur_fs_str = shell
88- . get_cur_dir ( Some ( fs_var) )
87+ . current_dir ( Some ( fs_var) )
8988 . expect ( "Could not get the current file system mapping" ) ;
9089 assert_ne ! ( cur_fs_str, expected_fs_str) ;
9190 let expected_fs_str = cstr16 ! ( "FS1:\\ " ) ;
@@ -94,11 +93,11 @@ pub fn test_cur_dir(shell: &ScopedProtocol<Shell>) {
9493 // Changing current file system and current directory
9594 let fs_var = cstr16 ! ( "fs0:" ) ;
9695 let dir_var = cstr16 ! ( "efi/" ) ;
97- let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
98- assert_eq ! ( status, Status :: SUCCESS ) ;
96+ let status = shell. set_current_dir ( Some ( fs_var) , Some ( dir_var) ) ;
97+ assert ! ( status. is_ok ( ) ) ;
9998
10099 let cur_fs_str = shell
101- . get_cur_dir ( Some ( fs_var) )
100+ . current_dir ( Some ( fs_var) )
102101 . expect ( "Could not get the current file system mapping" ) ;
103102 assert_ne ! ( cur_fs_str, expected_fs_str) ;
104103 let expected_fs_str = cstr16 ! ( "FS0:\\ efi" ) ;
@@ -108,50 +107,50 @@ pub fn test_cur_dir(shell: &ScopedProtocol<Shell>) {
108107
109108 // At this point, the current working file system has not been set
110109 // So we expect a NULL output
111- assert ! ( shell. get_cur_dir ( None ) . is_none( ) ) ;
110+ assert ! ( shell. current_dir ( None ) . is_none( ) ) ;
112111
113112 // Setting the current working file system and current working directory
114113 let dir_var = cstr16 ! ( "fs0:/" ) ;
115- let status = shell. set_cur_dir ( None , Some ( dir_var) ) ;
116- assert_eq ! ( status, Status :: SUCCESS ) ;
114+ let status = shell. set_current_dir ( None , Some ( dir_var) ) ;
115+ assert ! ( status. is_ok ( ) ) ;
117116 let cur_fs_str = shell
118- . get_cur_dir ( Some ( fs_var) )
117+ . current_dir ( Some ( fs_var) )
119118 . expect ( "Could not get the current file system mapping" ) ;
120119 let expected_fs_str = cstr16 ! ( "FS0:" ) ;
121120 assert_eq ! ( cur_fs_str, expected_fs_str) ;
122121
123122 let cur_fs_str = shell
124- . get_cur_dir ( None )
123+ . current_dir ( None )
125124 . expect ( "Could not get the current file system mapping" ) ;
126125 assert_eq ! ( cur_fs_str, expected_fs_str) ;
127126
128127 // Changing current working directory
129128 let dir_var = cstr16 ! ( "/efi" ) ;
130- let status = shell. set_cur_dir ( None , Some ( dir_var) ) ;
131- assert_eq ! ( status, Status :: SUCCESS ) ;
129+ let status = shell. set_current_dir ( None , Some ( dir_var) ) ;
130+ assert ! ( status. is_ok ( ) ) ;
132131 let cur_fs_str = shell
133- . get_cur_dir ( Some ( fs_var) )
132+ . current_dir ( Some ( fs_var) )
134133 . expect ( "Could not get the current file system mapping" ) ;
135134 let expected_fs_str = cstr16 ! ( "FS0:\\ efi" ) ;
136135 assert_eq ! ( cur_fs_str, expected_fs_str) ;
137136 let cur_fs_str = shell
138- . get_cur_dir ( None )
137+ . current_dir ( None )
139138 . expect ( "Could not get the current file system mapping" ) ;
140139 assert_eq ! ( cur_fs_str, expected_fs_str) ;
141140
142141 // Changing current directory in a non-current working file system
143142 let fs_var = cstr16 ! ( "fs0:" ) ;
144143 let dir_var = cstr16 ! ( "efi/tools" ) ;
145- let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
146- assert_eq ! ( status, Status :: SUCCESS ) ;
144+ let status = shell. set_current_dir ( Some ( fs_var) , Some ( dir_var) ) ;
145+ assert ! ( status. is_ok ( ) ) ;
147146 let cur_fs_str = shell
148- . get_cur_dir ( None )
147+ . current_dir ( None )
149148 . expect ( "Could not get the current file system mapping" ) ;
150149 assert_ne ! ( cur_fs_str, expected_fs_str) ;
151150
152151 let expected_fs_str = cstr16 ! ( "FS0:\\ efi\\ tools" ) ;
153152 let cur_fs_str = shell
154- . get_cur_dir ( Some ( fs_var) )
153+ . current_dir ( Some ( fs_var) )
155154 . expect ( "Could not get the current file system mapping" ) ;
156155 assert_eq ! ( cur_fs_str, expected_fs_str) ;
157156}
0 commit comments