1
1
use uefi:: boot;
2
- use uefi:: data_types:: Char16 ;
3
- use uefi:: proto:: shell:: { Shell , ShellFileHandle } ;
2
+ use uefi:: proto:: shell:: Shell ;
4
3
use uefi:: CStr16 ;
4
+ use uefi_raw:: Status ;
5
5
6
6
pub fn test ( ) {
7
7
info ! ( "Running shell protocol tests" ) ;
@@ -15,13 +15,14 @@ pub fn test() {
15
15
// let mut test_buf = [0u16; 12];
16
16
// let test_str = CStr16::from_str_with_buf("test", &mut test_buf).unwrap();
17
17
18
+ let mut test_buf = [ 0u16 ; 128 ] ;
19
+
18
20
/* Test retrieving list of environment variable names (null input) */
19
21
let cur_env_vec = shell
20
22
. get_env ( None )
21
23
. expect ( "Could not get environment variable" )
22
24
. vec ( )
23
25
. unwrap ( ) ;
24
- let mut test_buf = [ 0u16 ; 128 ] ;
25
26
assert_eq ! (
26
27
* cur_env_vec. get( 0 ) . unwrap( ) ,
27
28
CStr16 :: from_str_with_buf( "path" , & mut test_buf) . unwrap( )
@@ -52,23 +53,18 @@ pub fn test() {
52
53
. unwrap ( ) ;
53
54
assert_eq ! ( cur_env_str, test_val) ;
54
55
55
- // let mut cur_fs_buf = [0u16; 32];
56
- // let cur_fs_str = CStr16::from_str_with_buf("", &mut cur_fs_buf).unwrap();
57
- // info!("cur_fs_str size 1: {}", cur_fs_str.num_chars());
56
+ /* Test setting and getting current directory */
57
+ let mut fs_buf = [ 0u16 ; 16 ] ;
58
+ let fs_var = CStr16 :: from_str_with_buf ( "fs0:" , & mut fs_buf) . unwrap ( ) ;
59
+ let mut dir_buf = [ 0u16 ; 32 ] ;
60
+ let dir_var = CStr16 :: from_str_with_buf ( "/" , & mut dir_buf) . unwrap ( ) ;
61
+ let status = shell. set_cur_dir ( Some ( fs_var) , Some ( dir_var) ) ;
62
+ assert_eq ! ( status, Status :: SUCCESS ) ;
58
63
59
- // let cur_fs_str = shell.get_cur_dir(None).expect("Could not get the current file system mapping");
60
- // info!("cur_fs_str size: {}", cur_fs_str.num_chars());
61
- // info!("cur_fs_str: {}", cur_fs_str);
62
-
63
- // for (i, c) in cur_fs_str.iter().enumerate() {
64
- // info!("cur_fs_str: i: {}, c: {}", i, c);
65
- // }
64
+ let cur_fs_str = shell. get_cur_dir ( Some ( fs_var) ) . expect ( "Could not get the current file system mapping" ) ;
65
+ let expected_fs_str = CStr16 :: from_str_with_buf ( "FS0:\\ " , & mut test_buf) . unwrap ( ) ;
66
+ assert_eq ! ( cur_fs_str, expected_fs_str) ;
66
67
67
- // unsafe {
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
68
// Create a file
73
69
// let status = shell.create_file(test_str, 0).expect("Could not create file");
74
70
// let mut size: u64 = 0;
0 commit comments