[PATCH 2/2] linux-test (tests/tcg/multiarch/linux-test.c) add check

Taylor Simpson posted 2 patches 4 years, 7 months ago
There is a newer version of this series
[PATCH 2/2] linux-test (tests/tcg/multiarch/linux-test.c) add check
Posted by Taylor Simpson 4 years, 7 months ago
Add a check that the SIGSEGV handler is called

Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
---
 tests/tcg/multiarch/linux-test.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
index c8c6aed..cb845c9 100644
--- a/tests/tcg/multiarch/linux-test.c
+++ b/tests/tcg/multiarch/linux-test.c
@@ -439,10 +439,13 @@ static void sig_alarm(int sig)
     alarm_count++;
 }
 
+static int sig_segv_called;
+
 static void sig_segv(int sig, siginfo_t *info, void *puc)
 {
     if (sig != SIGSEGV)
         error("signal");
+    sig_segv_called = 1;
     longjmp(jmp_env, 1);
 }
 
@@ -492,6 +495,10 @@ static void test_signal(void)
         *(volatile uint8_t *)0 = 0;
     }
 
+    if (sig_segv_called == 0) {
+        error("SIGSEGV handler not called");
+    }
+
     act.sa_handler = SIG_DFL;
     sigemptyset(&act.sa_mask);
     act.sa_flags = 0;
-- 
2.7.4

Re: [PATCH 2/2] linux-test (tests/tcg/multiarch/linux-test.c) add check
Posted by Richard Henderson 4 years, 7 months ago
On 7/13/21 12:46 PM, Taylor Simpson wrote:
> Add a check that the SIGSEGV handler is called
> 
> Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
> ---
>   tests/tcg/multiarch/linux-test.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
> index c8c6aed..cb845c9 100644
> --- a/tests/tcg/multiarch/linux-test.c
> +++ b/tests/tcg/multiarch/linux-test.c
> @@ -439,10 +439,13 @@ static void sig_alarm(int sig)
>       alarm_count++;
>   }
>   
> +static int sig_segv_called;
> +
>   static void sig_segv(int sig, siginfo_t *info, void *puc)
>   {
>       if (sig != SIGSEGV)
>           error("signal");
> +    sig_segv_called = 1;

Either bool or a count.

Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

>       longjmp(jmp_env, 1);
>   }
>   
> @@ -492,6 +495,10 @@ static void test_signal(void)
>           *(volatile uint8_t *)0 = 0;
>       }
>   
> +    if (sig_segv_called == 0) {
> +        error("SIGSEGV handler not called");
> +    }
> +
>       act.sa_handler = SIG_DFL;
>       sigemptyset(&act.sa_mask);
>       act.sa_flags = 0;
>