Re: [PATCH v4 3/3] selftests: pci_endpoint: Migrate to Kselftest framework

Niklas Cassel
2024-12-31T17:42:48Z

On Tue, Dec 31, 2024 at 06:43:41PM +0530, Manivannan Sadhasivam wrote:

(...)

> + # RUN pci_ep_data_transfer.dma.COPY_TEST ...
> + # OK pci_ep_data_transfer.dma.COPY_TEST
> + ok 11 pci_ep_data_transfer.dma.COPY_TEST
> + # PASSED: 11 / 11 tests passed.
> + # Totals: pass:11 fail:0 xfail:0 xpass:0 skip:0 error:0
> +
> +
> +Testcase 11 (pci_ep_data_transfer.dma.COPY_TEST) will fail for most of the DMA
> +capable endpoint controllers due to the absence of the MEMCPY over DMA. For such
> +controllers, it is advisable to skip the forementioned testcase using below
> +command::

Hm.. this is strictly not correct. If will currently fail because pci-epf-test.c
does:
if ((reg->flags & FLAG_USE_DMA) && epf_test->dma_private)
return -EINVAL;

So even if a DMA driver has support for the DMA_MEMCPY cap, if the DMA driver
also has the DMA_PRIVATE cap, this test will fail because of the code in
pci-epf-test.c.

Not sure how to formulate this properly... Perhaps:
Testcase 11 (pci_ep_data_transfer.dma.COPY_TEST) will fail for DMA drivers that
have the DMA_PRIVATE cap set. For DMA drivers which have the DMA_PRIVATE cap
set, it is advisable to skip the forementioned testcase using below command::

> +
> + # pci_endpoint_test -f pci_ep_basic -v memcpy -T COPY_TEST -v dma

Is this really correct? I would guess that it should be
pci_endpoint_test -f pci_ep_data_transfer -v memcpy -T COPY_TEST -v dma

(...)

> +TEST_F(pci_ep_basic, BAR_TEST)
> +{
> + int ret, i;
> +
> + for (i = 0; i <= 5; i++) {
> + pci_ep_ioctl(PCITEST_BAR, i);
> + EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", i);
> + }
> +}

From looking at this function, will we still be able to test a single BAR?
Previous pcitest.c allowed us to do pcitest -b <barno> to only test a
specific BAR. I think that is a useful feature that we shouldn't remove.

It would be nice if we could do something like:
# pci_endpoint_test -f pci_ep_basic -T BAR_TEST -v <barno>

(...)

> +
> +TEST_F(pci_ep_data_transfer, COPY_TEST)
> +{
> + struct pci_endpoint_test_xfer_param param = {0};

This (also other places in this file) can be written as:
struct pci_endpoint_test_xfer_param param = {};

Kind regards,
Niklas