diff mbox

[kvm-unit-tests,v7,13/13] arm/arm64: pci: Add pci-testdev PCI device operation test

Message ID dfc3889efa9dce56daae23e0f92cb536350c3e3f.1471434672.git.agordeev@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Gordeev Aug. 17, 2016, 12:07 p.m. UTC
Suggested-by: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 arm/Makefile.common | 1 +
 arm/pci-test.c      | 8 ++++++++
 arm/run             | 7 ++++++-
 arm/unittests.cfg   | 4 ++++
 4 files changed, 19 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/arm/Makefile.common b/arm/Makefile.common
index 97179bbea4e7..f37b5c2a3de4 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -36,6 +36,7 @@  cflatobjs += lib/alloc.o
 cflatobjs += lib/devicetree.o
 cflatobjs += lib/pci.o
 cflatobjs += lib/pci-host-generic.o
+cflatobjs += lib/pci-testdev.o
 cflatobjs += lib/virtio.o
 cflatobjs += lib/virtio-mmio.o
 cflatobjs += lib/chr-testdev.o
diff --git a/arm/pci-test.c b/arm/pci-test.c
index daebdafceb60..10a367de5357 100644
--- a/arm/pci-test.c
+++ b/arm/pci-test.c
@@ -8,12 +8,20 @@ 
 #include <libcflat.h>
 #include <pci.h>
 
+#define NR_TESTS (PCI_TESTDEV_NUM_BARS * PCI_TESTDEV_NUM_TESTS)
+
 int main(void)
 {
+	int ret;
+
 	if (!pci_probe())
 		report_abort("PCI bus probing failed\n");
 
 	pci_print();
 
+	ret = pci_testdev();
+	report("PCI test device passed %d/%d tests",
+		ret >= NR_TESTS, ret > 0 ? ret : 0, NR_TESTS);
+
 	return report_summary();
 }
diff --git a/arm/run b/arm/run
index a2f35ef6a7e6..1ee6231599d6 100755
--- a/arm/run
+++ b/arm/run
@@ -67,8 +67,13 @@  fi
 chr_testdev='-device virtio-serial-device'
 chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
 
+pci_testdev=
+if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then
+	pci_testdev="-device pci-testdev"
+fi
+
 M+=",accel=$ACCEL"
-command="$qemu $M -cpu $processor $chr_testdev"
+command="$qemu $M -cpu $processor $chr_testdev $pci_testdev"
 command+=" -display none -serial stdio -kernel"
 command="$(timeout_cmd) $command"
 echo $command "$@"
diff --git a/arm/unittests.cfg b/arm/unittests.cfg
index ffd12e5794aa..20ffa0493c4c 100644
--- a/arm/unittests.cfg
+++ b/arm/unittests.cfg
@@ -51,3 +51,7 @@  file = selftest.flat
 smp = $MAX_SMP
 extra_params = -append 'smp'
 groups = selftest
+
+[pci-test]
+file = pci-test.flat
+groups = pci