Anastasia Klimchuk has uploaded this change for review.

View Change

tests: Remove mock struct pci_dev, use real pci symbols in tests

As a follow up on CB:62845 this patch removes mock struct
pci_dev and now tests are including pci/pci.h header and all
real symbols from the header.

Importantly, this means libpci now becomes a dependency
for tests (similar to how libusb is already a dependency for
tests as a result of
commit f47ff316ec79b014a5a37898d46e78e61acd6b01 )

BUG=b:181803212
TEST=ninja test

Change-Id: I1206fbdca392f190066a364376ce0db28071e53c
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M tests/io_mock.h
M tests/tests.c
2 files changed, 3 insertions(+), 8 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/48/62948/1
diff --git a/tests/io_mock.h b/tests/io_mock.h
index f8f75ad..95bcc6c 100644
--- a/tests/io_mock.h
+++ b/tests/io_mock.h
@@ -35,20 +35,15 @@
#include <stdio.h>

/*
- * Explicitly including the header because some tests are using libusb structs
+ * Explicitly including the headers because some tests are using structs
* in depth, opaque symbols are not sufficient.
*/
#include <libusb.h>
+#include <pci/pci.h>

/* Address value needs fit into uint8_t. */
#define USB_DEVICE_ADDRESS 19

-/* Define struct pci_dev to avoid dependency on pci.h */
-struct pci_dev {
- char padding[18];
- unsigned int device_id;
-};
-
/* POSIX open() flags, avoiding dependency on fcntl.h */
#define O_RDONLY 0
#define O_WRONLY 1
diff --git a/tests/tests.c b/tests/tests.c
index f1fb3f3..111648c 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -48,7 +48,7 @@
}

struct pci_dev mock_pci_dev = {
- .device_id = NON_ZERO,
+ .device_id = (short unsigned int) NON_ZERO,
};

struct pci_dev *__wrap_pcidev_init(void *devs, int bar)

To view, visit change 62948. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I1206fbdca392f190066a364376ce0db28071e53c
Gerrit-Change-Number: 62948
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-MessageType: newchange