tools/testing/memblock/tests/common.c
Source file repositories/reference/linux-study-clean/tools/testing/memblock/tests/common.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/memblock/tests/common.c- Extension
.c- Size
- 4668 bytes
- Lines
- 210
- 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
tests/common.hstring.hgetopt.hlinux/memory_hotplug.hlinux/build_bug.h
Detected Declarations
function reset_memblock_regionsfunction reset_memblock_attributesfunction fill_memblockfunction setup_memblockfunction unitsfunction dummy_physical_memory_initfunction dummy_physical_memory_cleanupfunction dummy_physical_memory_basefunction usagefunction parse_argsfunction print_prefixesfunction test_failfunction test_passfunction test_printfunction prefix_resetfunction prefix_pushfunction prefix_pop
Annotated Snippet
switch (c) {
case 'm':
movable_node_enabled = true;
break;
case 'v':
verbose = 1;
break;
default:
usage(argv[0]);
}
}
}
void print_prefixes(const char *postfix)
{
for (int i = 0; i < nr_prefixes; i++)
test_print("%s%s", prefixes[i], DELIM);
test_print(postfix);
}
void test_fail(void)
{
if (verbose) {
ksft_test_result_fail(": ");
print_prefixes("failed\n");
}
}
void test_pass(void)
{
if (verbose) {
ksft_test_result_pass(": ");
print_prefixes("passed\n");
}
}
void test_print(const char *fmt, ...)
{
if (verbose) {
int saved_errno = errno;
va_list args;
va_start(args, fmt);
errno = saved_errno;
vprintf(fmt, args);
va_end(args);
}
}
void prefix_reset(void)
{
memset(prefixes, 0, PREFIXES_MAX * sizeof(char *));
nr_prefixes = 0;
}
void prefix_push(const char *prefix)
{
assert(nr_prefixes < PREFIXES_MAX);
prefixes[nr_prefixes] = prefix;
nr_prefixes++;
}
void prefix_pop(void)
{
if (nr_prefixes > 0) {
prefixes[nr_prefixes - 1] = 0;
nr_prefixes--;
}
}
Annotation
- Immediate include surface: `tests/common.h`, `string.h`, `getopt.h`, `linux/memory_hotplug.h`, `linux/build_bug.h`.
- Detected declarations: `function reset_memblock_regions`, `function reset_memblock_attributes`, `function fill_memblock`, `function setup_memblock`, `function units`, `function dummy_physical_memory_init`, `function dummy_physical_memory_cleanup`, `function dummy_physical_memory_base`, `function usage`, `function parse_args`.
- 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.