tools/testing/selftests/powerpc/harness.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/harness.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/harness.c- Extension
.c- Size
- 2424 bytes
- Lines
- 134
- 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.hsignal.hstdbool.hstdio.hstdlib.hsys/types.hsys/wait.hunistd.helf.hfcntl.hlink.hsys/stat.hsubunit.hutils.h
Detected Declarations
function run_testfunction sig_handlerfunction test_harness_set_timeoutfunction test_harness
Annotated Snippet
if (errno != EINTR) {
printf("unknown error from waitpid\n");
return 1;
}
if (terminated) {
printf("!! force killing %s\n", name);
kill(-pid, SIGKILL);
return 1;
} else {
printf("!! killing %s\n", name);
kill(-pid, SIGTERM);
terminated = true;
alarm(KILL_TIMEOUT);
goto wait;
}
}
/* Kill anything else in the process group that is still running */
kill(-pid, SIGTERM);
if (WIFEXITED(status))
status = WEXITSTATUS(status);
else {
if (WIFSIGNALED(status))
printf("!! child died by signal %d\n", WTERMSIG(status));
else
printf("!! child died by unknown cause\n");
status = 1; /* Signal or other */
}
return status;
}
static void sig_handler(int signum)
{
/* Just wake us up from waitpid */
}
static struct sigaction sig_action = {
.sa_handler = sig_handler,
};
void test_harness_set_timeout(uint64_t time)
{
timeout = time;
}
int test_harness(int (test_function)(void), const char *name)
{
int rc;
test_start(name);
test_set_git_version(GIT_VERSION);
if (sigaction(SIGINT, &sig_action, NULL)) {
perror("sigaction (sigint)");
test_error(name);
return 1;
}
if (sigaction(SIGALRM, &sig_action, NULL)) {
perror("sigaction (sigalrm)");
test_error(name);
return 1;
}
rc = run_test(test_function, name);
if (rc == MAGIC_SKIP_RETURN_VALUE) {
test_skip(name);
/* so that skipped test is not marked as failed */
rc = 0;
} else
test_finish(name, rc);
return rc;
}
Annotation
- Immediate include surface: `errno.h`, `signal.h`, `stdbool.h`, `stdio.h`, `stdlib.h`, `sys/types.h`, `sys/wait.h`, `unistd.h`.
- Detected declarations: `function run_test`, `function sig_handler`, `function test_harness_set_timeout`, `function test_harness`.
- 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.