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,49 +42,49 @@ 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
67
- /// Test `get_cur_dir ()` and `set_cur_dir ()`
66
+ /// Test `current_dir ()` and `set_current_dir ()`
68
67
pub fn test_cur_dir ( shell : & ScopedProtocol < Shell > ) {
69
68
/* Test setting and getting current file system and current directory */
70
69
let fs_var = cstr16 ! ( "fs0:" ) ;
71
70
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 ( ) ) ;
74
73
75
74
let cur_fs_str = shell
76
- . get_cur_dir ( Some ( fs_var) )
75
+ . current_dir ( Some ( fs_var) )
77
76
. expect ( "Could not get the current file system mapping" ) ;
78
77
let expected_fs_str = cstr16 ! ( "FS0:\\ " ) ;
79
78
assert_eq ! ( cur_fs_str, expected_fs_str) ;
80
79
81
80
// Changing current file system
82
81
let fs_var = cstr16 ! ( "fs1:" ) ;
83
82
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 ( ) ) ;
86
85
87
86
let cur_fs_str = shell
88
- . get_cur_dir ( Some ( fs_var) )
87
+ . current_dir ( Some ( fs_var) )
89
88
. expect ( "Could not get the current file system mapping" ) ;
90
89
assert_ne ! ( cur_fs_str, expected_fs_str) ;
91
90
let expected_fs_str = cstr16 ! ( "FS1:\\ " ) ;
@@ -94,11 +93,11 @@ pub fn test_cur_dir(shell: &ScopedProtocol<Shell>) {
94
93
// Changing current file system and current directory
95
94
let fs_var = cstr16 ! ( "fs0:" ) ;
96
95
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 ( ) ) ;
99
98
100
99
let cur_fs_str = shell
101
- . get_cur_dir ( Some ( fs_var) )
100
+ . current_dir ( Some ( fs_var) )
102
101
. expect ( "Could not get the current file system mapping" ) ;
103
102
assert_ne ! ( cur_fs_str, expected_fs_str) ;
104
103
let expected_fs_str = cstr16 ! ( "FS0:\\ efi" ) ;
@@ -108,50 +107,50 @@ pub fn test_cur_dir(shell: &ScopedProtocol<Shell>) {
108
107
109
108
// At this point, the current working file system has not been set
110
109
// So we expect a NULL output
111
- assert ! ( shell. get_cur_dir ( None ) . is_none( ) ) ;
110
+ assert ! ( shell. current_dir ( None ) . is_none( ) ) ;
112
111
113
112
// Setting the current working file system and current working directory
114
113
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 ( ) ) ;
117
116
let cur_fs_str = shell
118
- . get_cur_dir ( Some ( fs_var) )
117
+ . current_dir ( Some ( fs_var) )
119
118
. expect ( "Could not get the current file system mapping" ) ;
120
119
let expected_fs_str = cstr16 ! ( "FS0:" ) ;
121
120
assert_eq ! ( cur_fs_str, expected_fs_str) ;
122
121
123
122
let cur_fs_str = shell
124
- . get_cur_dir ( None )
123
+ . current_dir ( None )
125
124
. expect ( "Could not get the current file system mapping" ) ;
126
125
assert_eq ! ( cur_fs_str, expected_fs_str) ;
127
126
128
127
// Changing current working directory
129
128
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 ( ) ) ;
132
131
let cur_fs_str = shell
133
- . get_cur_dir ( Some ( fs_var) )
132
+ . current_dir ( Some ( fs_var) )
134
133
. expect ( "Could not get the current file system mapping" ) ;
135
134
let expected_fs_str = cstr16 ! ( "FS0:\\ efi" ) ;
136
135
assert_eq ! ( cur_fs_str, expected_fs_str) ;
137
136
let cur_fs_str = shell
138
- . get_cur_dir ( None )
137
+ . current_dir ( None )
139
138
. expect ( "Could not get the current file system mapping" ) ;
140
139
assert_eq ! ( cur_fs_str, expected_fs_str) ;
141
140
142
141
// Changing current directory in a non-current working file system
143
142
let fs_var = cstr16 ! ( "fs0:" ) ;
144
143
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 ( ) ) ;
147
146
let cur_fs_str = shell
148
- . get_cur_dir ( None )
147
+ . current_dir ( None )
149
148
. expect ( "Could not get the current file system mapping" ) ;
150
149
assert_ne ! ( cur_fs_str, expected_fs_str) ;
151
150
152
151
let expected_fs_str = cstr16 ! ( "FS0:\\ efi\\ tools" ) ;
153
152
let cur_fs_str = shell
154
- . get_cur_dir ( Some ( fs_var) )
153
+ . current_dir ( Some ( fs_var) )
155
154
. expect ( "Could not get the current file system mapping" ) ;
156
155
assert_eq ! ( cur_fs_str, expected_fs_str) ;
157
156
}
0 commit comments