File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
uefi-test-runner/src/proto Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
29
29
target_arch = "aarch64"
30
30
) ) ]
31
31
shim:: test ( bt) ;
32
+ shell:: test ( bt) ;
32
33
tcg:: test ( bt) ;
33
34
}
34
35
@@ -69,6 +70,7 @@ mod rng;
69
70
target_arch = "arm" ,
70
71
target_arch = "aarch64"
71
72
) ) ]
73
+ mod shell;
72
74
mod shim;
73
75
mod string;
74
76
mod tcg;
Original file line number Diff line number Diff line change
1
+ use uefi:: CStr16 ;
2
+ use uefi:: prelude:: BootServices ;
3
+ use uefi:: proto:: shell:: Shell ;
4
+
5
+ pub fn test ( bt : & BootServices ) {
6
+ info ! ( "Running shell protocol tests" ) ;
7
+
8
+ let handle = bt. get_handle_for_protocol :: < Shell > ( ) . expect ( "No Shell handles" ) ;
9
+
10
+ let mut shell = bt
11
+ . open_protocol_exclusive :: < Shell > ( handle)
12
+ . expect ( "Failed to open Shell protocol" ) ;
13
+
14
+ // create some files
15
+ let mut test_buf = [ 0u16 ; 12 ] ;
16
+ let test_str = CStr16 :: from_str_with_buf ( "test" , & mut test_buf) . unwrap ( ) ;
17
+ shell. create_file ( test_str, 0 ) ;
18
+
19
+ // get file tree
20
+ let mut str_buf = [ 0u16 ; 12 ] ;
21
+ let str_str = CStr16 :: from_str_with_buf ( r"Z:\*" , & mut str_buf) . unwrap ( ) ;
22
+ let res = shell. find_files ( str_str) ;
23
+ let list = res. unwrap ( ) ;
24
+ let list = list. unwrap ( ) ;
25
+ let first = list. first ( ) ;
26
+
27
+ info ! ( "filetree test successful" )
28
+ }
Original file line number Diff line number Diff line change @@ -175,7 +175,11 @@ impl Shell {
175
175
/// TODO
176
176
pub fn find_files ( & self , file_pattern : & CStr16 ) -> Result < Option < FileList > > {
177
177
let mut out_list: MaybeUninit < * mut ShellFileInfo > = MaybeUninit :: uninit ( ) ;
178
- ( self . find_files ) ( file_pattern, out_list. as_mut_ptr ( ) ) . to_result_with_val ( || {
178
+ let mut out_ptr = out_list. as_mut_ptr ( ) ;
179
+ if out_ptr. is_null ( ) {
180
+ panic ! ( "outptr null" ) ;
181
+ }
182
+ ( self . find_files ) ( file_pattern, out_ptr) . to_result_with_val ( || {
179
183
// safety: if we're here, out_list is valid, but maybe null
180
184
let out_list = unsafe { out_list. assume_init ( ) } ;
181
185
if out_list. is_null ( ) {
You can’t perform that action at this time.
0 commit comments