@@ -118,7 +118,7 @@ fn create_kernel_args<T: AsStr, U: AsStr>(test_name: T, file_path: U) -> Vec<Str
118118fn generate_params (
119119 filemap_params : Option < Vec < String > > ,
120120 test_name : & ' static str ,
121- guest_path : & PathBuf ,
121+ guest_path : Option < PathBuf > ,
122122) -> Params {
123123 Params {
124124 cpu_count : 2 . try_into ( ) . unwrap ( ) ,
@@ -129,7 +129,11 @@ fn generate_params(
129129 file_mapping : filemap_params. unwrap_or_default ( ) ,
130130 #[ cfg( target_os = "linux" ) ]
131131 file_isolation : strict_sandbox ( ) ,
132- kernel_args : create_kernel_args ( test_name, guest_path) ,
132+ // A default value is chosen to make debugging investigations a bit easier.
133+ kernel_args : create_kernel_args (
134+ test_name,
135+ & guest_path. unwrap_or ( PathBuf :: from ( "./no_guest_path_needed" ) ) ,
136+ ) ,
133137 ..Default :: default ( )
134138 }
135139}
@@ -153,7 +157,11 @@ fn create_mapped_parent_nonpresent_file() {
153157
154158 let uhyvefilemap_params = create_filemap_params ( & host_dir_path, & guest_dir_path) ;
155159
156- let params = generate_params ( uhyvefilemap_params. into ( ) , test_name, & guest_file_path) ;
160+ let params = generate_params (
161+ uhyvefilemap_params. into ( ) ,
162+ test_name,
163+ guest_file_path. into ( ) ,
164+ ) ;
157165
158166 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
159167 let res = run_vm_in_thread ( bin_path, params) ;
@@ -178,7 +186,11 @@ fn create_write_mapped_nonpresent_file() {
178186
179187 let uhyvefilemap_params = create_filemap_params ( & host_file_path, & guest_file_path) ;
180188
181- let params = generate_params ( uhyvefilemap_params. into ( ) , test_name, & guest_file_path) ;
189+ let params = generate_params (
190+ uhyvefilemap_params. into ( ) ,
191+ test_name,
192+ guest_file_path. into ( ) ,
193+ ) ;
182194
183195 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
184196 let res = run_vm_in_thread ( bin_path, params) ;
@@ -200,7 +212,7 @@ fn create_write_unmapped_nonpresent_file() {
200212 let mut guest_file_path = guest_dir_path. clone ( ) ;
201213 guest_file_path. push ( & filename) ;
202214
203- let params = generate_params ( None , testname, & guest_file_path) ;
215+ let params = generate_params ( None , testname, guest_file_path. into ( ) ) ;
204216
205217 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
206218 let res = run_vm_in_thread ( bin_path, params) ;
@@ -230,7 +242,11 @@ fn remove_mapped_present_file() {
230242
231243 let uhyvefilemap_params = create_filemap_params ( & host_file_path, & guest_file_path) ;
232244
233- let params = generate_params ( uhyvefilemap_params. into ( ) , test_name, & guest_file_path) ;
245+ let params = generate_params (
246+ uhyvefilemap_params. into ( ) ,
247+ test_name,
248+ guest_file_path. into ( ) ,
249+ ) ;
234250
235251 assert ! ( host_file_path. exists( ) ) ;
236252 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
@@ -263,7 +279,11 @@ fn remove_mapped_parent_present_file() {
263279
264280 let uhyvefilemap_params = create_filemap_params ( & host_dir_path, & guest_dir_path) ;
265281
266- let params = generate_params ( uhyvefilemap_params. into ( ) , test_name, & guest_file_path) ;
282+ let params = generate_params (
283+ uhyvefilemap_params. into ( ) ,
284+ test_name,
285+ guest_file_path. into ( ) ,
286+ ) ;
267287
268288 assert ! ( host_file_path. exists( ) ) ;
269289 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
@@ -282,7 +302,7 @@ fn remove_nonpresent_file_test() {
282302
283303 let test_name: & ' static str = "remove_nonpresent_file_test" ;
284304 let guest_file_path = get_testname_derived_guest_path ( test_name) ;
285- let params = generate_params ( None , test_name, & guest_file_path) ;
305+ let params = generate_params ( None , test_name, guest_file_path. into ( ) ) ;
286306
287307 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
288308 let res = run_vm_in_thread ( bin_path, params) ;
@@ -297,7 +317,7 @@ fn fd_open_remove_close() {
297317
298318 let test_name: & ' static str = "fd_open_remove_close" ;
299319 let ( filemap, guest_file_path, _tmpdir) = create_filemap ( test_name) ;
300- let params = generate_params ( Some ( filemap) , test_name, & guest_file_path) ;
320+ let params = generate_params ( Some ( filemap) , test_name, guest_file_path. into ( ) ) ;
301321
302322 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
303323 let res = run_vm_in_thread ( bin_path, params) ;
@@ -312,7 +332,7 @@ fn fd_open_remove_before_and_after_closing() {
312332
313333 let test_name: & ' static str = "fd_open_remove_before_and_after_closing" ;
314334 let guest_file_path = get_testname_derived_guest_path ( test_name) ;
315- let params = generate_params ( None , test_name, & guest_file_path) ;
335+ let params = generate_params ( None , test_name, guest_file_path. into ( ) ) ;
316336
317337 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
318338 let res = run_vm_in_thread ( bin_path, params) ;
@@ -327,7 +347,7 @@ fn fd_remove_twice_before_closing() {
327347
328348 let test_name: & ' static str = "fd_remove_twice_before_closing" ;
329349 let guest_file_path = get_testname_derived_guest_path ( test_name) ;
330- let params = generate_params ( None , test_name, & guest_file_path) ;
350+ let params = generate_params ( None , test_name, guest_file_path. into ( ) ) ;
331351
332352 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
333353 let res = run_vm_in_thread ( bin_path, params) ;
@@ -342,7 +362,7 @@ fn open_read_only_write() {
342362
343363 let test_name: & ' static str = "open_read_only_write" ;
344364 let ( filemap, guest_file_path, _tmpdir) = create_filemap ( test_name) ;
345- let params = generate_params ( Some ( filemap) , test_name, & guest_file_path) ;
365+ let params = generate_params ( Some ( filemap) , test_name, guest_file_path. into ( ) ) ;
346366
347367 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
348368
@@ -364,20 +384,27 @@ fn open_read_only_write() {
364384fn fd_write_to_fd ( ) {
365385 env_logger:: try_init ( ) . ok ( ) ;
366386
367- let params = Params {
368- cpu_count : 2 . try_into ( ) . unwrap ( ) ,
369- memory_size : Byte :: from_u64_with_unit ( 32 , Unit :: MiB )
370- . unwrap ( )
371- . try_into ( )
372- . unwrap ( ) ,
373- #[ cfg( target_os = "linux" ) ]
374- file_isolation : strict_sandbox ( ) ,
375- ..Default :: default ( )
376- } ;
377-
378- let bin_path: PathBuf = build_hermit_bin ( "write_to_fd" , BuildMode :: Debug ) ;
387+ let test_name: & ' static str = "write_to_fd" ;
388+ let mut params = generate_params ( None , test_name, None ) ;
389+ // This is a one-time thing... for now. If this is used in more tests,
390+ // a toggle should become part of generate_params.
391+ params. output = uhyvelib:: params:: Output :: Buffer ;
392+ let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
379393 let res = run_vm_in_thread ( bin_path, params) ;
380394 check_result ( & res) ;
395+ // The file descriptors are standard streams.
396+ assert ! (
397+ res. output
398+ . as_ref( )
399+ . unwrap( )
400+ . contains( "Wrote to stdout manually!" )
401+ ) ;
402+ assert ! (
403+ res. output
404+ . as_ref( )
405+ . unwrap( )
406+ . contains( "Wrote to stderr manually!" )
407+ ) ;
381408}
382409
383410#[ test]
@@ -414,8 +441,7 @@ fn mounts_test() {
414441 ( & host_dir_path) . as_str( ) ,
415442 ) ,
416443 ] ;
417- let guest_file_path = get_testname_derived_guest_path ( test_name) ;
418- let params = generate_params ( uhyvefilemap_params. into ( ) , test_name, & guest_file_path) ;
444+ let params = generate_params ( uhyvefilemap_params. into ( ) , test_name, None ) ;
419445
420446 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
421447 let res = run_vm_in_thread ( bin_path, params) ;
@@ -428,7 +454,7 @@ fn lseek_test() {
428454
429455 let test_name: & ' static str = "lseek_file" ;
430456 let ( filemap, guest_file_path, _tmpdir) = create_filemap ( test_name) ;
431- let params = generate_params ( Some ( filemap) , test_name, & guest_file_path) ;
457+ let params = generate_params ( Some ( filemap) , test_name, guest_file_path. into ( ) ) ;
432458
433459 let bin_path: PathBuf = build_hermit_bin ( "fs_tests" , BuildMode :: Debug ) ;
434460 let res = run_vm_in_thread ( bin_path, params) ;
0 commit comments