Re: [kvm-unit-tests PATCH v5 12/12] arm/arm64: pci: Add pci-testdev PCI device operation test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 20, 2016 at 08:23:08PM +0200, Alexander Gordeev wrote:
> Cc: Thomas Huth <thuth@xxxxxxxxxx>
> Cc: Andrew Jones <drjones@xxxxxxxxxx>
> Reviewed-by: Andrew Jones <drjones@xxxxxxxxxx>
> Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxx>
> ---
>  arm/Makefile.common |  1 +
>  arm/pci-test.c      | 14 ++++++++++++--
>  arm/run             |  7 ++++++-
>  3 files changed, 19 insertions(+), 3 deletions(-)
> 
> 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 fde5495dd626..be228320e8c7 100644
> --- a/arm/pci-test.c
> +++ b/arm/pci-test.c
> @@ -13,9 +13,19 @@ int main(void)
>  	int ret = pci_probe();
>  
>  	report("PCI bus probing", ret);
> +	if (!ret)
> +		goto done;

I don't think probing should be a test. The only way it can currently
fail is if the DT isn't found, or if the DT doesn't contain the pcie
host bridge. For arm (mach-virt) neither of those should ever happen.
Instead we should complain loudly and abort. Calling abort will allow
you to remove the label and gotos too.

>  
> -	if (ret)
> -		pci_print();
> +	pci_print();
>  
> +	if (pci_find_dev(PCI_VENDOR_ID_REDHAT,
> +			 PCI_DEVICE_ID_REDHAT_TEST) == PCIDEVADDR_INVALID)

If you add the error messages to the previous patch that I suggested,
then you don't need this.

> +		goto done;
> +
> +	ret = pci_testdev();
> +	report("PCI test device passed %d tests",
> +		ret >= PCI_TESTDEV_NUM_BARS * PCI_TESTDEV_NUM_TESTS, ret);

If pci_testdev returns -1 then you'll report that -1 tests passed. We
need to convert that to 0. Also we need know how many tests were attempted
so we can report the more informative ...passed %d/%d tests.

> +
> +done:
>  	return report_summary();

Just to be clear how I think this should look

 #define NR_TESTS (PCI_TESTDEV_NUM_BARS * PCI_TESTDEV_NUM_TESTS)
 main()
 {
   if (!pci_probe()) {
      printf(...);
      abort();
   }

   pci_print();

   ret = pci_testdev();
   report("...%d/%d...", 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 "$@"
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux