tools/perf/tests/tests-scripts.c
Source file repositories/reference/linux-study-clean/tools/perf/tests/tests-scripts.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/tests-scripts.c- Extension
.c- Size
- 7235 bytes
- Lines
- 295
- 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
dirent.herrno.hfcntl.hlinux/ctype.hlinux/kernel.hlinux/string.hlinux/zalloc.hstring.hstdlib.hsys/types.hunistd.hsubcmd/exec-cmd.hsubcmd/parse-options.hsys/wait.hsys/stat.hapi/io.hbuiltin.htests-scripts.hcolor.hdebug.hhist.hintlist.hstring2.hsymbol.htests.hutil/rlimit.hutil/util.h
Detected Declarations
function shell_tests__dir_fdfunction is_shell_scriptfunction is_test_scriptfunction shell_test__runfunction append_scriptfunction append_scripts_in_dir
Annotated Snippet
if (is_test_script(dir_fd, ent->d_name)) { /* It's a test */
char *desc = shell_test__description(dir_fd, ent->d_name);
if (desc) /* It has a desc line - valid script */
append_script(dir_fd, ent->d_name, desc, result, result_sz);
continue;
}
if (ent->d_type != DT_DIR) {
struct stat st;
if (ent->d_type != DT_UNKNOWN)
continue;
fstatat(dir_fd, ent->d_name, &st, 0);
if (!S_ISDIR(st.st_mode))
continue;
}
if (strncmp(ent->d_name, "base_", 5) == 0)
continue; /* Skip scripts that have a separate driver. */
fd = openat(dir_fd, ent->d_name, O_PATH);
append_scripts_in_dir(fd, result, result_sz);
close(fd);
}
for (i = 0; i < n_dirs; i++) /* Clean up */
zfree(&entlist[i]);
free(entlist);
}
struct test_suite **create_script_test_suites(void)
{
struct test_suite **result = NULL, **result_tmp;
size_t result_sz = 0;
int dir_fd = shell_tests__dir_fd(); /* Walk dir */
/*
* Append scripts if fd is good, otherwise return a NULL terminated zero
* length array.
*/
if (dir_fd >= 0)
append_scripts_in_dir(dir_fd, &result, &result_sz);
result_tmp = realloc(result, (result_sz + 1) * sizeof(*result_tmp));
if (result_tmp == NULL) {
pr_err("Out of memory while building script test suite list\n");
abort();
}
/* NULL terminate the test suite array. */
result = result_tmp;
result[result_sz] = NULL;
if (dir_fd >= 0)
close(dir_fd);
return result;
}
Annotation
- Immediate include surface: `dirent.h`, `errno.h`, `fcntl.h`, `linux/ctype.h`, `linux/kernel.h`, `linux/string.h`, `linux/zalloc.h`, `string.h`.
- Detected declarations: `function shell_tests__dir_fd`, `function is_shell_script`, `function is_test_script`, `function shell_test__run`, `function append_script`, `function append_scripts_in_dir`.
- 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.