From 846505d360efd1b6b16b57a8bf5b9ef04578af8c Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 2 Aug 2019 10:58:43 -0700 Subject: [PATCH] pci: Fix add_capability unit test The structure provided to the add_capability() function should only contain what comes after the capability ID and the next capability pointer, which are located on the first WORD. Because the structure TestCap included _vndr and _next fields, they were directly set after the first WORD, while the assertion was expecting to find the values of len and foo fields. Fixes #105 Signed-off-by: Sebastien Boeuf --- pci/src/configuration.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pci/src/configuration.rs b/pci/src/configuration.rs index 023a2f649..6f1744b96 100755 --- a/pci/src/configuration.rs +++ b/pci/src/configuration.rs @@ -710,8 +710,6 @@ mod tests { #[derive(Clone, Copy, Default)] #[allow(dead_code)] struct TestCap { - _vndr: u8, - _next: u8, len: u8, foo: u8, } @@ -730,7 +728,6 @@ mod tests { } #[test] - #[ignore] fn add_capability() { let mut cfg = PciConfiguration::new( 0x1234, @@ -745,18 +742,11 @@ mod tests { ); // Add two capabilities with different contents. - let cap1 = TestCap { - _vndr: 0, - _next: 0, - len: 4, - foo: 0xAA, - }; + let cap1 = TestCap { len: 4, foo: 0xAA }; let cap1_offset = cfg.add_capability(&cap1).unwrap(); assert_eq!(cap1_offset % 4, 0); let cap2 = TestCap { - _vndr: 0, - _next: 0, len: 0x04, foo: 0x55, };