11use uefi:: boot;
2- use uefi:: data_types:: Char16 ;
3- use uefi:: proto:: shell:: { Shell , ShellFileHandle } ;
2+ use uefi:: proto:: shell:: Shell ;
43use uefi:: CStr16 ;
4+ use uefi_raw:: Status ;
55
66pub fn test ( ) {
77 info ! ( "Running shell protocol tests" ) ;
@@ -15,13 +15,14 @@ pub fn test() {
1515 // let mut test_buf = [0u16; 12];
1616 // let test_str = CStr16::from_str_with_buf("test", &mut test_buf).unwrap();
1717
18+ let mut test_buf = [ 0u16 ; 128 ] ;
19+
1820 /* Test retrieving list of environment variable names (null input) */
1921 let cur_env_vec = shell
2022 . get_env ( None )
2123 . expect ( "Could not get environment variable" )
2224 . vec ( )
2325 . unwrap ( ) ;
24- let mut test_buf = [ 0u16 ; 128 ] ;
2526 assert_eq ! (
2627 * cur_env_vec. get( 0 ) . unwrap( ) ,
2728 CStr16 :: from_str_with_buf( "path" , & mut test_buf) . unwrap( )
@@ -52,23 +53,18 @@ pub fn test() {
5253 . unwrap ( ) ;
5354 assert_eq ! ( cur_env_str, test_val) ;
5455
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 ) ;
5863
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) ;
6667
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- // //
7268 // Create a file
7369 // let status = shell.create_file(test_str, 0).expect("Could not create file");
7470 // let mut size: u64 = 0;
0 commit comments