mirror of
https://github.com/dgibson/dtc.git
synced 2026-07-10 13:29:48 -04:00
tests: More portable installation of SIGINT handler
Our tests install SIGINT handlers using sigaction(), but that isn't available on Windows / mingw, blocking use of the tests there. Use the more portable signal() instead - it's good enough for our needs. Avoid strsignal() for the same reason. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
84d13508d5
commit
d320877b07
2 changed files with 8 additions and 10 deletions
|
|
@ -86,6 +86,7 @@ See the "AI Coding Assistants" section in CONTRIBUTING.md. Key rules:
|
|||
- **Do not** add `Signed-off-by` tags — only humans can certify the DCO
|
||||
- Use `Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]` for attribution in commit messages
|
||||
- The human submitter is responsible for reviewing all AI-generated code and ensuring license compliance
|
||||
- Do not add `Co-authored-by` tags.
|
||||
|
||||
## Tagging a New Release
|
||||
|
||||
|
|
|
|||
|
|
@ -42,24 +42,21 @@ static inline void VALGRIND_MAKE_MEM_DEFINED(void *p, size_t len)
|
|||
int verbose_test = 1;
|
||||
char *test_name;
|
||||
|
||||
static void sigint_handler(int signum, siginfo_t *si, void *uc)
|
||||
static void sigint_handler(int signum)
|
||||
{
|
||||
fprintf(stderr, "%s: %s (pid=%d)\n", test_name,
|
||||
strsignal(signum), getpid());
|
||||
fprintf(stderr, "%s: signal %d (pid=%d)\n", test_name,
|
||||
signum, getpid());
|
||||
exit(RC_BUG);
|
||||
}
|
||||
|
||||
void test_init(int argc, char *argv[])
|
||||
{
|
||||
int err;
|
||||
struct sigaction sa_int = {
|
||||
.sa_sigaction = sigint_handler,
|
||||
};
|
||||
|
||||
test_name = argv[0];
|
||||
|
||||
err = sigaction(SIGINT, &sa_int, NULL);
|
||||
if (err)
|
||||
/* Use signal(), not sigaction() because it also works on the Windows /
|
||||
* mingw environments we support.
|
||||
*/
|
||||
if (signal(SIGINT, sigint_handler) == SIG_ERR)
|
||||
FAIL("Can't install SIGINT handler");
|
||||
|
||||
if (getenv("QUIET_TEST"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue