Skip to content
Permalink
Browse files
PCI: Add KUnit tests for __pci_read_base()
It is usually hard to debug issues in the resource assignment code due
to long reporduction cycles between the developer trying to fix the code
and the user testing it.

This adds KUnit tests for __pci_read_base() which is only  dependent
on software structures, so no hardware is needed to run these.

This lays the foundation for test fixtures we can use to reproduce the
resource assignment code path of PCI.

Sample output from KUnit Test run:

  Subtest: __pci_read_base()
     1..2
     # test_pci_read_base_type_0_hdr_approach_1: initializing __pci_read_base() tests
  (null): reg 0x18: [mem 0x4f400000-0x4f400fff]
     ok 1 - test_pci_read_base_type_0_hdr_approach_1
     # test_pci_read_base_type_0_hdr_approach_2: initializing __pci_read_base() tests
  (null): reg 0x18: [mem 0x4f400000-0x4f400fff]
     ok 2 - test_pci_read_base_type_0_hdr_approach_2
  # __pci_read_base(): pass:2 fail:0 skip:0 total:2
  # Totals: pass:2 fail:0 skip:0 total:2
  ok 2 - __pci_read_base()

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
  • Loading branch information
Naveenaidu authored and intel-lab-lkp committed Nov 14, 2021
1 parent dda4b38 commit 57b950c5684fcfff54e46f4369fd7f708a29ca60
Show file tree
Hide file tree
Showing 3 changed files with 747 additions and 0 deletions.
@@ -252,6 +252,10 @@ config PCIE_BUS_PEER2PEER

endchoice

config PCI_READ_BASE_KUNIT_TEST
tristate "KUnit tests for __pci_read_base() in probe.c"
depends on PCI && KUNIT=y

source "drivers/pci/hotplug/Kconfig"
source "drivers/pci/controller/Kconfig"
source "drivers/pci/endpoint/Kconfig"
@@ -36,4 +36,7 @@ obj-$(CONFIG_PCI_ENDPOINT) += endpoint/
obj-y += controller/
obj-y += switch/

# KUnit test files
obj-$(CONFIG_PCI_READ_BASE_KUNIT_TEST) += pci-read-base-test.o

subdir-ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG

0 comments on commit 57b950c

Please sign in to comment.