Skip to content

Commit 350e505

Browse files
committed
Ran cargo fmt and updated get_env() tests
1 parent aed094f commit 350e505

File tree

1 file changed

+35
-22
lines changed

1 file changed

+35
-22
lines changed

uefi-test-runner/src/proto/shell.rs

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use uefi::boot;
2+
use uefi::data_types::Char16;
23
use uefi::proto::shell::{Shell, ShellFileHandle};
34
use uefi::CStr16;
4-
use uefi::data_types::Char16;
55

66
pub fn test() {
77
info!("Running shell protocol tests");
@@ -16,16 +16,27 @@ pub fn test() {
1616
// let test_str = CStr16::from_str_with_buf("test", &mut test_buf).unwrap();
1717

1818
/* Test retrieving list of environment variable names (null input) */
19-
let cur_env_vec = shell.get_env(None).expect("Could not get environment variable").vec().unwrap();
20-
let mut test_buf = [0u16; 64];
21-
assert_eq!(*cur_env_vec.get(0).unwrap(), CStr16::from_str_with_buf("path", &mut test_buf).unwrap());
22-
assert_eq!(*cur_env_vec.get(1).unwrap(), CStr16::from_str_with_buf("nonesting", &mut test_buf).unwrap());
19+
let cur_env_vec = shell
20+
.get_env(None)
21+
.expect("Could not get environment variable")
22+
.vec()
23+
.unwrap();
24+
let mut test_buf = [0u16; 128];
25+
assert_eq!(
26+
*cur_env_vec.get(0).unwrap(),
27+
CStr16::from_str_with_buf("path", &mut test_buf).unwrap()
28+
);
29+
assert_eq!(
30+
*cur_env_vec.get(1).unwrap(),
31+
CStr16::from_str_with_buf("nonesting", &mut test_buf).unwrap()
32+
);
2333

24-
// Debug statements TODO: Remove
25-
info!("cur_env_vec size: {}", cur_env_vec.len());
26-
for (i, env_var) in cur_env_vec.iter().enumerate() {
27-
info!("i: {}, env_var: {}", i, env_var);
28-
}
34+
let path_val = shell
35+
.get_env(Some(cur_env_vec.get(0).unwrap()))
36+
.expect("Could not get path")
37+
.val()
38+
.unwrap();
39+
assert_eq!(path_val, CStr16::from_str_with_buf("FS0:\\efi\\tools\\;FS0:\\efi\\boot\\;FS0:\\;FS1:\\efi\\tools\\;FS1:\\efi\\boot\\;FS1:\\;FS2:\\efi\\tools\\;FS2:\\efi\\boot\\;FS2:\\", &mut test_buf).unwrap());
2940

3041
/* Test setting and getting a specific environment variable */
3142
let mut test_env_buf = [0u16; 32];
@@ -34,33 +45,35 @@ pub fn test() {
3445
let test_val = CStr16::from_str_with_buf("test_val", &mut test_val_buf).unwrap();
3546
assert!(shell.get_env(Some(test_var)).is_none());
3647
shell.set_env(test_var, test_val, false);
37-
let cur_env_str = shell.get_env(Some(test_var)).expect("Could not get environment variable").val().unwrap();
48+
let cur_env_str = shell
49+
.get_env(Some(test_var))
50+
.expect("Could not get environment variable")
51+
.val()
52+
.unwrap();
3853
assert_eq!(cur_env_str, test_val);
3954

4055
// let mut cur_fs_buf = [0u16; 32];
4156
// let cur_fs_str = CStr16::from_str_with_buf("", &mut cur_fs_buf).unwrap();
4257
// info!("cur_fs_str size 1: {}", cur_fs_str.num_chars());
4358

44-
4559
// let cur_fs_str = shell.get_cur_dir(None).expect("Could not get the current file system mapping");
4660
// info!("cur_fs_str size: {}", cur_fs_str.num_chars());
4761
// info!("cur_fs_str: {}", cur_fs_str);
4862

49-
5063
// for (i, c) in cur_fs_str.iter().enumerate() {
5164
// info!("cur_fs_str: i: {}, c: {}", i, c);
5265
// }
5366

5467
// unsafe {
55-
// info!("cur_fs_str: {}", cur_fs_str);
56-
// let mut expected_fs_str_buf = [0u16; 32];
57-
// assert_eq!(cur_fs_str, CStr16::from_str_with_buf("", &mut expected_fs_str_buf).unwrap());
58-
// //
59-
// Create a file
60-
// let status = shell.create_file(test_str, 0).expect("Could not create file");
61-
// let mut size: u64 = 0;
62-
// shell.get_file_size(f_handle, &mut size);
63-
// assert_eq!(size, 0);
68+
// info!("cur_fs_str: {}", cur_fs_str);
69+
// let mut expected_fs_str_buf = [0u16; 32];
70+
// assert_eq!(cur_fs_str, CStr16::from_str_with_buf("", &mut expected_fs_str_buf).unwrap());
71+
// //
72+
// Create a file
73+
// let status = shell.create_file(test_str, 0).expect("Could not create file");
74+
// let mut size: u64 = 0;
75+
// shell.get_file_size(f_handle, &mut size);
76+
// assert_eq!(size, 0);
6477
// }
6578

6679
// get file tree

0 commit comments

Comments
 (0)