@@ -381,3 +381,55 @@ pub fn test_timeout_submit_args<S: squeue::EntryMarker, C: cqueue::EntryMarker>(
381
381
382
382
Ok ( ( ) )
383
383
}
384
+
385
+ pub fn test_timeout_submit_args_min_wait < S : squeue:: EntryMarker , C : cqueue:: EntryMarker > (
386
+ ring : & mut IoUring < S , C > ,
387
+ test : & Test ,
388
+ ) -> anyhow:: Result < ( ) > {
389
+ require ! {
390
+ test;
391
+ ring. params( ) . is_feature_ext_arg( ) ;
392
+ ring. params( ) . is_feature_min_timeout( ) ;
393
+ } ;
394
+
395
+ println ! ( "test timeout_submit_args_min_wait" ) ;
396
+
397
+ let ts = types:: Timespec :: new ( ) . sec ( 2 ) ;
398
+ let args = types:: SubmitArgs :: new ( )
399
+ . timespec ( & ts)
400
+ . min_wait_usec ( 1_000_000 ) ;
401
+
402
+ // timeout
403
+
404
+ let start = Instant :: now ( ) ;
405
+ match ring. submitter ( ) . submit_with_args ( 2 , & args) {
406
+ Ok ( _) => panic ! ( ) ,
407
+ Err ( ref err) if err. raw_os_error ( ) == Some ( libc:: ETIME ) => ( ) ,
408
+ Err ( err) => return Err ( err. into ( ) ) ,
409
+ }
410
+ assert_eq ! ( start. elapsed( ) . as_secs( ) , 2 ) ;
411
+
412
+ assert ! ( ring. completion( ) . next( ) . is_none( ) ) ;
413
+
414
+ // no timeout
415
+
416
+ let nop_e = opcode:: Nop :: new ( ) ;
417
+
418
+ unsafe {
419
+ ring. submission ( )
420
+ . push ( & nop_e. build ( ) . user_data ( 0x1d ) . into ( ) )
421
+ . expect ( "queue is full" ) ;
422
+ }
423
+
424
+ let start = Instant :: now ( ) ;
425
+ ring. submitter ( ) . submit_with_args ( 2 , & args) ?;
426
+ assert_eq ! ( start. elapsed( ) . as_secs( ) , 1 ) ;
427
+
428
+ let cqes: Vec < cqueue:: Entry > = ring. completion ( ) . map ( Into :: into) . collect ( ) ;
429
+
430
+ assert_eq ! ( cqes. len( ) , 1 ) ;
431
+ assert_eq ! ( cqes[ 0 ] . user_data( ) , 0x1d ) ;
432
+ assert_eq ! ( cqes[ 0 ] . result( ) , 0 ) ;
433
+
434
+ Ok ( ( ) )
435
+ }
0 commit comments