tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/pci_endpoint/pci_endpoint_test.c- Extension
.c- Size
- 6507 bytes
- Lines
- 290
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hfcntl.hstdbool.hstdio.hstdlib.hsys/ioctl.hunistd.h../../../../include/uapi/linux/pcitest.hkselftest_harness.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Kselftest for PCI Endpoint Subsystem
*
* Copyright (c) 2022 Samsung Electronics Co., Ltd.
* https://www.samsung.com
* Author: Aman Gupta <aman1.gupta@samsung.com>
*
* Copyright (c) 2024, Linaro Ltd.
* Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
*/
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "../../../../include/uapi/linux/pcitest.h"
#include "kselftest_harness.h"
#define pci_ep_ioctl(cmd, arg) \
({ \
ret = ioctl(self->fd, cmd, arg); \
ret = ret < 0 ? -errno : ret; \
})
static const char *test_device = "/dev/pci-endpoint-test.0";
static const unsigned long test_size[5] = { 1, 1024, 1025, 1024000, 1024001 };
FIXTURE(pci_ep_bar)
{
int fd;
};
FIXTURE_SETUP(pci_ep_bar)
{
self->fd = open(test_device, O_RDWR);
ASSERT_NE(-1, self->fd) TH_LOG("Can't open PCI Endpoint Test device");
}
FIXTURE_TEARDOWN(pci_ep_bar)
{
close(self->fd);
}
FIXTURE_VARIANT(pci_ep_bar)
{
int barno;
};
FIXTURE_VARIANT_ADD(pci_ep_bar, BAR0) { .barno = 0 };
FIXTURE_VARIANT_ADD(pci_ep_bar, BAR1) { .barno = 1 };
FIXTURE_VARIANT_ADD(pci_ep_bar, BAR2) { .barno = 2 };
FIXTURE_VARIANT_ADD(pci_ep_bar, BAR3) { .barno = 3 };
FIXTURE_VARIANT_ADD(pci_ep_bar, BAR4) { .barno = 4 };
FIXTURE_VARIANT_ADD(pci_ep_bar, BAR5) { .barno = 5 };
TEST_F(pci_ep_bar, BAR_TEST)
{
int ret;
pci_ep_ioctl(PCITEST_BAR, variant->barno);
if (ret == -ENODATA)
SKIP(return, "BAR is disabled");
if (ret == -ENOBUFS)
SKIP(return, "BAR is reserved");
EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
}
TEST_F(pci_ep_bar, BAR_SUBRANGE_TEST)
{
int ret;
pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_AUTO);
ASSERT_EQ(0, ret) TH_LOG("Can't set AUTO IRQ type");
pci_ep_ioctl(PCITEST_BAR_SUBRANGE, variant->barno);
if (ret == -ENODATA)
SKIP(return, "BAR is disabled");
if (ret == -EBUSY)
SKIP(return, "BAR is test register space");
if (ret == -EOPNOTSUPP)
SKIP(return, "Subrange map is not supported");
if (ret == -ENOBUFS)
SKIP(return, "BAR is reserved");
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `stdbool.h`, `stdio.h`, `stdlib.h`, `sys/ioctl.h`, `unistd.h`, `../../../../include/uapi/linux/pcitest.h`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.