xref: /kvm-unit-tests/arm/pci-test.c (revision a299895b7abb54e7ba6bb4108f202acbb484ac65)
1 /*
2  * PCI bus operation test
3  *
4  * Copyright (C) 2016, Red Hat Inc, Alexander Gordeev <agordeev@redhat.com>
5  *
6  * This work is licensed under the terms of the GNU LGPL, version 2.
7  */
8 #include <libcflat.h>
9 #include <pci.h>
10 
11 #define NR_TESTS (PCI_TESTDEV_NUM_BARS * PCI_TESTDEV_NUM_TESTS)
12 
main(void)13 int main(void)
14 {
15 	int ret;
16 
17 	if (!pci_probe()) {
18 		printf("PCI bus probing failed, skipping tests...\n");
19 		return report_summary();
20 	}
21 
22 	report_prefix_push("pci");
23 
24 	pci_print();
25 
26 	ret = pci_testdev();
27 	if (ret == -1)
28 		report_skip("No PCI test device");
29 	else
30 		report(ret >= NR_TESTS, "PCI test device passed %d/%d tests",
31 		       ret > 0 ? ret : 0, NR_TESTS);
32 
33 	return report_summary();
34 }
35