From 7cfc244df8a46c767f17368a727b780befb8527e Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 13 Mar 2009 05:38:01 +0000 Subject: [PATCH] Merge r9380, r9381 (test portability tweaks) from the DARWIN branch. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9394 --- none/tests/coolo_sigaction.cpp | 2 +- none/tests/coolo_sigaction.stdout.exp | 2 +- none/tests/sigstackgrowth.c | 25 +++++++++++++++++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/none/tests/coolo_sigaction.cpp b/none/tests/coolo_sigaction.cpp index 7baa4aef42..2481746465 100644 --- a/none/tests/coolo_sigaction.cpp +++ b/none/tests/coolo_sigaction.cpp @@ -8,7 +8,7 @@ static struct sigaction oldChildHandlerData; void theHandler(int arg) { - printf("handled %d\n", arg); + printf("handled %s\n", arg == SIGCHLD ? "SIGCHLD" : "?!unexpected signal?!" ); } void setupHandlers() diff --git a/none/tests/coolo_sigaction.stdout.exp b/none/tests/coolo_sigaction.stdout.exp index 652c76e2fa..600b45fe45 100644 --- a/none/tests/coolo_sigaction.stdout.exp +++ b/none/tests/coolo_sigaction.stdout.exp @@ -1 +1 @@ -handled 17 +handled SIGCHLD diff --git a/none/tests/sigstackgrowth.c b/none/tests/sigstackgrowth.c index 3b40896bc0..3f687961cd 100644 --- a/none/tests/sigstackgrowth.c +++ b/none/tests/sigstackgrowth.c @@ -4,9 +4,25 @@ #include #include -#if defined(_AIX) && !defined(SA_NOMASK) -# define SA_NOMASK 0 -#endif +/* What does this test do? It checks that valgrind's signal frame + building mechanism can create at least 4MB of signal delivery + frames, hence that it can actually expand the stack by that much + when delivering signals. A fair-enough thing to want to test. + + It does this by getting into the signal handler, and then + recursively invoking the handler by sending itself the signal + again, until the stack has grown to 4MB from the starting frame + (main). + + Consequence is: it is essential that we do not disable delivery of + further signals within the handler itself, else the kernel will + wait till the handler exits before delivering the next signal, the + frame will be cleared, the stack will never grow, and we'll be in + an infinite loop. + + Hence we *must* give the SA_NODEFER flag when setting up the + handler. +*/ static char *deep; @@ -32,7 +48,7 @@ int main() deep = &here - SIZE; sa.sa_handler = handler; - sa.sa_flags = SA_NOMASK; + sa.sa_flags = SA_NODEFER; sigemptyset(&sa.sa_mask); sigaction(SIGUSR1, &sa, NULL); @@ -42,3 +58,4 @@ int main() printf("FAILED\n"); exit(1); } + -- 2.47.3