tools/testing/selftests/resctrl/resctrl_tests.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/resctrl/resctrl_tests.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/resctrl/resctrl_tests.c- Extension
.c- Size
- 9017 bytes
- Lines
- 363
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
resctrl.h
Detected Declarations
function detect_vendorfunction get_vendorfunction cmd_helpfunction test_preparefunction test_cleanupfunction test_vendor_specific_checkfunction run_single_testfunction defaultsfunction init_user_paramsfunction main
Annotated Snippet
if (errno || *endptr != '\0') {
free(fill_param);
ksft_exit_skip("Unable to parse benchmark buffer size.\n");
}
} else {
fill_param->buf_size = MINIMUM_SPAN;
}
if (uparams->benchmark_cmd[2] && *uparams->benchmark_cmd[2] != '\0') {
errno = 0;
fill_param->memflush = strtol(uparams->benchmark_cmd[2], &endptr, 10) != 0;
if (errno || *endptr != '\0') {
free(fill_param);
ksft_exit_skip("Unable to parse benchmark memflush parameter.\n");
}
} else {
fill_param->memflush = true;
}
if (uparams->benchmark_cmd[3] && *uparams->benchmark_cmd[3] != '\0') {
if (strcmp(uparams->benchmark_cmd[3], "0")) {
free(fill_param);
ksft_exit_skip("Only read operations supported.\n");
}
}
if (uparams->benchmark_cmd[4] && *uparams->benchmark_cmd[4] != '\0') {
if (strcmp(uparams->benchmark_cmd[4], "false")) {
free(fill_param);
ksft_exit_skip("fill_buf is required to run until termination.\n");
}
}
return fill_param;
}
static void init_user_params(struct user_params *uparams)
{
memset(uparams, 0, sizeof(*uparams));
uparams->cpu = 1;
uparams->bits = 0;
}
int main(int argc, char **argv)
{
struct fill_buf_param *fill_param = NULL;
int tests = ARRAY_SIZE(resctrl_tests);
bool test_param_seen = false;
struct user_params uparams;
int c, i;
init_user_params(&uparams);
while ((c = getopt(argc, argv, "ht:b:n:p:")) != -1) {
char *token;
switch (c) {
case 'b':
/*
* First move optind back to the (first) optarg and
* then build the benchmark command using the
* remaining arguments.
*/
optind--;
if (argc - optind >= BENCHMARK_ARGS)
ksft_exit_fail_msg("Too long benchmark command");
/* Extract benchmark command from command line. */
for (i = 0; i < argc - optind; i++)
uparams.benchmark_cmd[i] = argv[i + optind];
uparams.benchmark_cmd[i] = NULL;
goto last_arg;
case 't':
token = strtok(optarg, ",");
if (!test_param_seen) {
for (i = 0; i < ARRAY_SIZE(resctrl_tests); i++)
resctrl_tests[i]->disabled = true;
tests = 0;
test_param_seen = true;
}
while (token) {
bool found = false;
for (i = 0; i < ARRAY_SIZE(resctrl_tests); i++) {
if (!strcasecmp(token, resctrl_tests[i]->name) ||
(resctrl_tests[i]->group &&
!strcasecmp(token, resctrl_tests[i]->group))) {
Annotation
- Immediate include surface: `resctrl.h`.
- Detected declarations: `function detect_vendor`, `function get_vendor`, `function cmd_help`, `function test_prepare`, `function test_cleanup`, `function test_vendor_specific_check`, `function run_single_test`, `function defaults`, `function init_user_params`, `function main`.
- 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.