3
3
use uefi:: boot:: ScopedProtocol ;
4
4
use uefi:: proto:: shell:: Shell ;
5
5
use uefi:: { boot, cstr16} ;
6
- use uefi_raw:: Status ;
7
6
8
- /// Test `get_env ()`, `get_envs ()`, and `set_env ()`
7
+ /// Test `var ()`, `vars ()`, and `set_var ()`
9
8
pub fn test_env ( shell : & ScopedProtocol < Shell > ) {
10
9
/* Test retrieving list of environment variable names */
11
- let mut cur_env_vec = shell. get_envs ( ) ;
10
+ let mut cur_env_vec = shell. vars ( ) ;
12
11
assert_eq ! ( cur_env_vec. next( ) . unwrap( ) , cstr16!( "path" ) , ) ;
13
12
// check pre-defined shell variables; see UEFI Shell spec
14
13
assert_eq ! ( cur_env_vec. next( ) . unwrap( ) , cstr16!( "nonesting" ) , ) ;
15
- let cur_env_vec = shell. get_envs ( ) ;
14
+ let cur_env_vec = shell. vars ( ) ;
16
15
let default_len = cur_env_vec. count ( ) ;
17
16
18
17
/* Test setting and getting a specific environment variable */
19
- let cur_env_vec = shell. get_envs ( ) ;
18
+ let cur_env_vec = shell. vars ( ) ;
20
19
let test_var = cstr16 ! ( "test_var" ) ;
21
20
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 ( ) ) ;
25
24
let cur_env_str = shell
26
- . get_env ( test_var)
25
+ . var ( test_var)
27
26
. expect ( "Could not get environment variable" ) ;
28
27
assert_eq ! ( cur_env_str, test_val) ;
29
28
@@ -34,7 +33,7 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
34
33
}
35
34
}
36
35
assert ! ( !found_var) ;
37
- let cur_env_vec = shell. get_envs ( ) ;
36
+ let cur_env_vec = shell. vars ( ) ;
38
37
let mut found_var = false ;
39
38
for env_var in cur_env_vec {
40
39
if env_var == test_var {
@@ -43,24 +42,24 @@ pub fn test_env(shell: &ScopedProtocol<Shell>) {
43
42
}
44
43
assert ! ( found_var) ;
45
44
46
- let cur_env_vec = shell. get_envs ( ) ;
45
+ let cur_env_vec = shell. vars ( ) ;
47
46
assert_eq ! ( cur_env_vec. count( ) , default_len + 1 ) ;
48
47
49
48
/* Test deleting environment variable */
50
49
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( ) ) ;
54
53
55
- let cur_env_vec = shell. get_envs ( ) ;
54
+ let cur_env_vec = shell. vars ( ) ;
56
55
let mut found_var = false ;
57
56
for env_var in cur_env_vec {
58
57
if env_var == test_var {
59
58
found_var = true ;
60
59
}
61
60
}
62
61
assert ! ( !found_var) ;
63
- let cur_env_vec = shell. get_envs ( ) ;
62
+ let cur_env_vec = shell. vars ( ) ;
64
63
assert_eq ! ( cur_env_vec. count( ) , default_len) ;
65
64
}
66
65
0 commit comments