@@ -5,14 +5,12 @@ use uefi::proto::shell::Shell;
55use uefi:: { CStr16 , boot} ;
66use uefi_raw:: Status ;
77
8- /// Test ``get_env()`` and ``set_env()``
8+ /// Test ``get_env()``, ``get_envs()``, and ``set_env()``
99pub fn test_env ( shell : & ScopedProtocol < Shell > ) {
1010 let mut test_buf = [ 0u16 ; 128 ] ;
1111
12- /* Test retrieving list of environment variable names (null input) */
13- let cur_env_vec = shell
14- . get_env ( None )
15- . expect ( "Could not get environment variable" ) ;
12+ /* Test retrieving list of environment variable names */
13+ let cur_env_vec = shell. get_envs ( ) ;
1614 assert_eq ! (
1715 * cur_env_vec. first( ) . unwrap( ) ,
1816 CStr16 :: from_str_with_buf( "path" , & mut test_buf) . unwrap( )
@@ -21,27 +19,35 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
2119 * cur_env_vec. get( 1 ) . unwrap( ) ,
2220 CStr16 :: from_str_with_buf( "nonesting" , & mut test_buf) . unwrap( )
2321 ) ;
22+ let default_len = cur_env_vec. len ( ) ;
2423
2524 /* Test setting and getting a specific environment variable */
2625 let mut test_env_buf = [ 0u16 ; 32 ] ;
2726 let test_var = CStr16 :: from_str_with_buf ( "test_var" , & mut test_env_buf) . unwrap ( ) ;
2827 let mut test_val_buf = [ 0u16 ; 32 ] ;
2928 let test_val = CStr16 :: from_str_with_buf ( "test_val" , & mut test_val_buf) . unwrap ( ) ;
30- assert ! ( shell. get_env( Some ( test_var) ) . is_none( ) ) ;
29+ assert ! ( shell. get_env( test_var) . is_none( ) ) ;
3130 let status = shell. set_env ( test_var, test_val, false ) ;
3231 assert_eq ! ( status, Status :: SUCCESS ) ;
33- let cur_env_str = * shell
34- . get_env ( Some ( test_var) )
35- . expect ( "Could not get environment variable" )
36- . first ( )
37- . unwrap ( ) ;
32+ let cur_env_str = shell
33+ . get_env ( test_var)
34+ . expect ( "Could not get environment variable" ) ;
3835 assert_eq ! ( cur_env_str, test_val) ;
3936
37+ assert ! ( !cur_env_vec. contains( & test_var) ) ;
38+ let cur_env_vec = shell. get_envs ( ) ;
39+ assert ! ( cur_env_vec. contains( & test_var) ) ;
40+ assert_eq ! ( cur_env_vec. len( ) , default_len + 1 ) ;
41+
4042 /* Test deleting environment variable */
4143 let test_val = CStr16 :: from_str_with_buf ( "" , & mut test_val_buf) . unwrap ( ) ;
4244 let status = shell. set_env ( test_var, test_val, false ) ;
4345 assert_eq ! ( status, Status :: SUCCESS ) ;
44- assert ! ( shell. get_env( Some ( test_var) ) . is_none( ) ) ;
46+ assert ! ( shell. get_env( test_var) . is_none( ) ) ;
47+
48+ let cur_env_vec = shell. get_envs ( ) ;
49+ assert ! ( !cur_env_vec. contains( & test_var) ) ;
50+ assert_eq ! ( cur_env_vec. len( ) , default_len) ;
4551}
4652
4753/// Test ``get_cur_dir()`` and ``set_cur_dir()``
0 commit comments