tools/testing/selftests/arm64/signal/test_signals_utils.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/arm64/signal/test_signals_utils.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/arm64/signal/test_signals_utils.c- Extension
.c- Size
- 11032 bytes
- Lines
- 425
- 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
stdio.hstdlib.hsignal.hstring.hunistd.hassert.hsys/auxv.hlinux/auxvec.hucontext.hasm/unistd.hkselftest.htest_signals.htest_signals_utils.htestcases/testcases.h
Detected Declarations
function unblock_signalfunction default_resultfunction handle_signal_unsupportedfunction handle_signal_triggerfunction handle_signal_okfunction arm64_notify_segfaultfunction handle_signal_copyctxfunction default_handlerfunction handle_signal_triggerfunction handle_signal_okfunction handle_signal_copyctxfunction default_setupfunction default_triggerfunction test_initfunction test_setupfunction test_runfunction test_resultfunction test_cleanup
Annotated Snippet
if (feats & (1UL << i)) {
size_t tlen = strlen(feats_names[i]);
assert(flen > tlen);
flen -= tlen;
strncat(feats_string, feats_names[i], flen);
}
}
return feats_string;
}
static void unblock_signal(int signum)
{
sigset_t sset;
sigemptyset(&sset);
sigaddset(&sset, signum);
sigprocmask(SIG_UNBLOCK, &sset, NULL);
}
static void default_result(struct tdescr *td, bool force_exit)
{
if (td->result == KSFT_SKIP) {
fprintf(stderr, "==>> completed. SKIP.\n");
} else if (td->pass) {
fprintf(stderr, "==>> completed. PASS(1)\n");
td->result = KSFT_PASS;
} else {
fprintf(stdout, "==>> completed. FAIL(0)\n");
td->result = KSFT_FAIL;
}
if (force_exit)
exit(td->result);
}
/*
* The following handle_signal_* helpers are used by main default_handler
* and are meant to return true when signal is handled successfully:
* when false is returned instead, it means that the signal was somehow
* unexpected in that context and it was NOT handled; default_handler will
* take care of such unexpected situations.
*/
static bool handle_signal_unsupported(struct tdescr *td,
siginfo_t *si, void *uc)
{
if (feats_ok(td))
return false;
/* Mangling PC to avoid loops on original SIGILL */
((ucontext_t *)uc)->uc_mcontext.pc += 4;
if (!td->initialized) {
fprintf(stderr,
"Got SIG_UNSUPP @test_init. Ignore.\n");
} else {
fprintf(stderr,
"-- RX SIG_UNSUPP on unsupported feat...OK\n");
td->pass = 1;
default_result(current, 1);
}
return true;
}
static bool handle_signal_trigger(struct tdescr *td,
siginfo_t *si, void *uc)
{
td->triggered = 1;
/* ->run was asserted NON-NULL in test_setup() already */
td->run(td, si, uc);
return true;
}
static bool handle_signal_ok(struct tdescr *td,
siginfo_t *si, void *uc)
{
/*
* it's a bug in the test code when this assert fail:
* if sig_trig was defined, it must have been used before getting here.
*/
assert(!td->sig_trig || td->triggered);
fprintf(stderr,
"SIG_OK -- SP:0x%llX si_addr@:%p si_code:%d token@:%p offset:%ld\n",
((ucontext_t *)uc)->uc_mcontext.sp,
si->si_addr, si->si_code, td->token, td->token - si->si_addr);
/*
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `signal.h`, `string.h`, `unistd.h`, `assert.h`, `sys/auxv.h`, `linux/auxvec.h`.
- Detected declarations: `function unblock_signal`, `function default_result`, `function handle_signal_unsupported`, `function handle_signal_trigger`, `function handle_signal_ok`, `function arm64_notify_segfault`, `function handle_signal_copyctx`, `function default_handler`, `function handle_signal_trigger`, `function handle_signal_ok`.
- 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.