tools/testing/selftests/net/proc_net_pktgen.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/proc_net_pktgen.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/proc_net_pktgen.c- Extension
.c- Size
- 23148 bytes
- Lines
- 691
- 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.
Dependency Surface
errno.hfcntl.hstdlib.hunistd.hkselftest_harness.h
Detected Declarations
function TEST_Ffunction TEST_F
Annotated Snippet
if (i < (sizeof(legacy_thr_cmd) - 1)) {
/* incomplete command string */
EXPECT_EQ(len, -1);
EXPECT_EQ(errno, EINVAL);
} else {
/* complete command string without/with trailing '\0' */
EXPECT_EQ(len, i);
}
}
}
TEST_F(proc_net_pktgen, wrong_dev_cmd) {
for (int i = 0; i <= sizeof(wrong_dev_cmd); i++) {
ssize_t len;
len = write(self->dev_fd, wrong_dev_cmd, i);
EXPECT_EQ(len, -1);
EXPECT_EQ(errno, EINVAL);
}
}
TEST_F(proc_net_pktgen, dev_cmd_min_pkt_size) {
ssize_t len;
/* with trailing '\0' */
len = write(self->dev_fd, dev_cmd_min_pkt_size_0, sizeof(dev_cmd_min_pkt_size_0));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_0));
/* without trailing '\0' */
len = write(self->dev_fd, dev_cmd_min_pkt_size_0, sizeof(dev_cmd_min_pkt_size_0) - 1);
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_0) - 1);
/* with trailing '\0' */
len = write(self->dev_fd, dev_cmd_min_pkt_size_1, sizeof(dev_cmd_min_pkt_size_1));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_1));
/* without trailing '\0' */
len = write(self->dev_fd, dev_cmd_min_pkt_size_1, sizeof(dev_cmd_min_pkt_size_1) - 1);
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_1) - 1);
/* with trailing '\0' */
len = write(self->dev_fd, dev_cmd_min_pkt_size_2, sizeof(dev_cmd_min_pkt_size_2));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_2));
/* without trailing '\0' */
len = write(self->dev_fd, dev_cmd_min_pkt_size_2, sizeof(dev_cmd_min_pkt_size_2) - 1);
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_2) - 1);
len = write(self->dev_fd, dev_cmd_min_pkt_size_3, sizeof(dev_cmd_min_pkt_size_3));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_3));
len = write(self->dev_fd, dev_cmd_min_pkt_size_4, sizeof(dev_cmd_min_pkt_size_4));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_4));
len = write(self->dev_fd, dev_cmd_min_pkt_size_5, sizeof(dev_cmd_min_pkt_size_5));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_5));
len = write(self->dev_fd, dev_cmd_min_pkt_size_6, sizeof(dev_cmd_min_pkt_size_6));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_6));
len = write(self->dev_fd, dev_cmd_min_pkt_size_7, sizeof(dev_cmd_min_pkt_size_7));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_7));
len = write(self->dev_fd, dev_cmd_min_pkt_size_8, sizeof(dev_cmd_min_pkt_size_8));
EXPECT_EQ(len, sizeof(dev_cmd_min_pkt_size_8));
}
TEST_F(proc_net_pktgen, dev_cmd_max_pkt_size) {
ssize_t len;
len = write(self->dev_fd, dev_cmd_max_pkt_size_0, sizeof(dev_cmd_max_pkt_size_0));
EXPECT_EQ(len, sizeof(dev_cmd_max_pkt_size_0));
}
TEST_F(proc_net_pktgen, dev_cmd_pkt_size) {
ssize_t len;
len = write(self->dev_fd, dev_cmd_pkt_size_0, sizeof(dev_cmd_pkt_size_0));
EXPECT_EQ(len, sizeof(dev_cmd_pkt_size_0));
}
TEST_F(proc_net_pktgen, dev_cmd_imix_weights) {
ssize_t len;
len = write(self->dev_fd, dev_cmd_imix_weights_0, sizeof(dev_cmd_imix_weights_0));
EXPECT_EQ(len, sizeof(dev_cmd_imix_weights_0));
len = write(self->dev_fd, dev_cmd_imix_weights_1, sizeof(dev_cmd_imix_weights_1));
EXPECT_EQ(len, sizeof(dev_cmd_imix_weights_1));
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `stdlib.h`, `unistd.h`, `kselftest_harness.h`.
- Detected declarations: `function TEST_F`, `function TEST_F`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.