aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2022-10-14 15:36:58 -0400
committerAustin Clements <austin@google.com>2022-10-17 15:15:34 +0000
commita81da928b4891f111e40dfca677d3c90d1411f0d (patch)
tree5f02d28b17808b1fbd93802396de9c6f06e5dee8 /src/runtime/testdata
parentdacf88e40a0a3d395988d226b5e43e046dd7e68f (diff)
downloadgo-a81da928b4891f111e40dfca677d3c90d1411f0d.tar.xz
runtime: improve coverage of TestCgoSigfwd
Currently, TestCgoSigfwd will pass incorrectly if the SIGSEGV that originates in Go mistakenly goes to the C SIGSEGV handler. Fix this by adding a signal-atomic variable that tracks what the expected behavior is. Change-Id: Id2a9fa3b209299dccf90bb60720b89ad96838a9c Reviewed-on: https://go-review.googlesource.com/c/go/+/443072 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r--src/runtime/testdata/testprogcgo/sigfwd.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprogcgo/sigfwd.go b/src/runtime/testdata/testprogcgo/sigfwd.go
index 1694289700..b27d436f82 100644
--- a/src/runtime/testdata/testprogcgo/sigfwd.go
+++ b/src/runtime/testdata/testprogcgo/sigfwd.go
@@ -17,8 +17,11 @@ import (
#include <stdio.h>
#include <string.h>
+sig_atomic_t expectCSigsegv;
int *sigfwdP;
+
static void sigsegv() {
+ expectCSigsegv = 1;
*sigfwdP = 1;
fprintf(stderr, "ERROR: C SIGSEGV not thrown on caught?.\n");
exit(2);
@@ -26,6 +29,10 @@ static void sigsegv() {
static void segvhandler(int signum) {
if (signum == SIGSEGV) {
+ if (expectCSigsegv == 0) {
+ fprintf(stderr, "SIGSEGV caught in C unexpectedly\n");
+ exit(1);
+ }
fprintf(stdout, "OK\n");
exit(0); // success
}