aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata/testprogcgo/threadprof.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-01-18 18:46:00 -0800
committerIan Lance Taylor <iant@golang.org>2022-01-20 19:24:26 +0000
commit2c2e08144f79d8746384c2a483bf03532dc0c443 (patch)
tree03d6c6174cb84db7f94cc1fa1fb98c7f173f9e10 /src/runtime/testdata/testprogcgo/threadprof.go
parent65535bfe6dad2cb7535f6a5647b288e4489608f9 (diff)
downloadgo-2c2e08144f79d8746384c2a483bf03532dc0c443.tar.xz
runtime: remove -tags=threadprof in tests
Use an enviroment variable rather than a build tag to control starting a busy loop thread when testprogcgo starts. This lets us skip another build that invokes the C compiler and linker, which should avoid timeouts running the runtime tests. Fixes #44422 Change-Id: I516668d71a373da311d844990236566ff63e6d72 Reviewed-on: https://go-review.googlesource.com/c/go/+/379294 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/testdata/testprogcgo/threadprof.go')
-rw-r--r--src/runtime/testdata/testprogcgo/threadprof.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/runtime/testdata/testprogcgo/threadprof.go b/src/runtime/testdata/testprogcgo/threadprof.go
index 8081173c0f..d62d4b4be8 100644
--- a/src/runtime/testdata/testprogcgo/threadprof.go
+++ b/src/runtime/testdata/testprogcgo/threadprof.go
@@ -2,21 +2,22 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// We only build this file with the tag "threadprof", since it starts
-// a thread running a busy loop at constructor time.
-
-//go:build !plan9 && !windows && threadprof
-// +build !plan9,!windows,threadprof
+//go:build !plan9 && !windows
+// +build !plan9,!windows
package main
/*
#include <stdint.h>
+#include <stdlib.h>
#include <signal.h>
#include <pthread.h>
volatile int32_t spinlock;
+// Note that this thread is only started if GO_START_SIGPROF_THREAD
+// is set in the environment, which is only done when running the
+// CgoExternalThreadSIGPROF test.
static void *thread1(void *p) {
(void)p;
while (spinlock == 0)
@@ -26,9 +27,13 @@ static void *thread1(void *p) {
return NULL;
}
+// This constructor function is run when the program starts.
+// It is used for the CgoExternalThreadSIGPROF test.
__attribute__((constructor)) void issue9456() {
- pthread_t tid;
- pthread_create(&tid, 0, thread1, NULL);
+ if (getenv("GO_START_SIGPROF_THREAD") != NULL) {
+ pthread_t tid;
+ pthread_create(&tid, 0, thread1, NULL);
+ }
}
void **nullptr;