@@ -643,6 +643,10 @@ impl From<IoRedTblEntry> for u64 {
643
643
644
644
#[ cfg( test) ]
645
645
mod test {
646
+
647
+ use log:: Level ;
648
+ extern crate testing_logger;
649
+
646
650
use super :: * ;
647
651
648
652
fn get_ioapic ( buf : * mut u8 ) -> Result < IoApic > {
@@ -674,17 +678,22 @@ mod test {
674
678
675
679
#[ test]
676
680
fn ioredtblentry_invalid_trigger_mode ( ) {
681
+ testing_logger:: setup ( ) ;
677
682
// ExtINT is invalid for level trigger mode.
678
683
let invalid_for_level = 0x0f000000_00008700 ;
679
684
let err = Error :: InvalidValue ;
680
- // (
681
- // "The delivery mode `0b111` is invalid for level trigger mode"
682
- // .to_string(),
683
- // );
684
685
assert_eq ! (
685
686
IoRedTblEntry :: try_from( invalid_for_level) . unwrap_err( ) ,
686
687
err
687
688
) ;
689
+ testing_logger:: validate ( |captured_logs| {
690
+ assert_eq ! ( captured_logs. len( ) , 1 ) ;
691
+ assert_eq ! (
692
+ captured_logs[ 0 ] . body,
693
+ "The delivery mode `0b111` is invalid for level trigger mode"
694
+ ) ;
695
+ assert_eq ! ( captured_logs[ 0 ] . level, Level :: Error ) ;
696
+ } )
688
697
}
689
698
690
699
#[ test]
@@ -700,16 +709,23 @@ mod test {
700
709
fn ioredtblentry_invalid_dest ( ) {
701
710
// Destination is a full byte but a physical destination mode
702
711
// is used.
712
+ testing_logger:: setup ( ) ;
703
713
let invalid_dest = 0xff000000_0000_0000 ;
704
714
let err = Error :: InvalidValue ;
705
- // (
706
- // "Invalid Physical APIC ID destination: 0xff".to_string(),
707
- // );
708
715
assert_eq ! ( err, IoRedTblEntry :: try_from( invalid_dest) . unwrap_err( ) ) ;
716
+ testing_logger:: validate ( |captured_logs| {
717
+ assert_eq ! ( captured_logs. len( ) , 1 ) ;
718
+ assert_eq ! (
719
+ captured_logs[ 0 ] . body,
720
+ "Invalid Physical APIC ID destination: 0xff"
721
+ ) ;
722
+ assert_eq ! ( captured_logs[ 0 ] . level, Level :: Error ) ;
723
+ } )
709
724
}
710
725
711
726
#[ test]
712
727
fn ioredtblentry_write_ro_bit ( ) {
728
+ testing_logger:: setup ( ) ;
713
729
let mut buf: [ u8 ; 24 ] = [
714
730
0x00 ,
715
731
0x00 ,
@@ -741,11 +757,16 @@ mod test {
741
757
let entry = IoRedTblEntry :: try_from ( bits) . unwrap ( ) ;
742
758
743
759
let err = Error :: InvalidValue ;
744
- // (
745
- // "Read-only IO Redirect Table Entry bits set: 0x1000".to_string(),
746
- // );
747
760
// The delivery status is set, which should be read-only.
748
761
assert_eq ! ( err, ioapic. write_ioredtbl( 0 , entry) . unwrap_err( ) ) ;
762
+ testing_logger:: validate ( |captured_logs| {
763
+ assert_eq ! ( captured_logs. len( ) , 1 ) ;
764
+ assert_eq ! (
765
+ captured_logs[ 0 ] . body,
766
+ "Read-only IO Redirect Table Entry bits set: 0x1000"
767
+ ) ;
768
+ assert_eq ! ( captured_logs[ 0 ] . level, Level :: Error ) ;
769
+ } )
749
770
}
750
771
751
772
#[ test]
0 commit comments