From 28a15e3df34258f4f6c1de319fa30a81356ee92c Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 28 Oct 2019 22:19:32 -0400 Subject: [PATCH] runtime: rename TestPreemptM to TestSignalM TestPreemptM doesn't test preemptM, it tests signalM. Rename it and co-locate it with the other tests related to signals. Change-Id: I7b95f2ba96530c49cfa8d5bf33282946b5f2d9af Reviewed-on: https://go-review.googlesource.com/c/go/+/203891 Run-TryBot: Austin Clements Reviewed-by: Brad Fitzpatrick Reviewed-by: Cherry Zhang TryBot-Result: Gobot Gobot --- src/runtime/crash_unix_test.go | 24 +++++++++++++++++++++++ src/runtime/preemptm_test.go | 35 ---------------------------------- 2 files changed, 24 insertions(+), 35 deletions(-) delete mode 100644 src/runtime/preemptm_test.go diff --git a/src/runtime/crash_unix_test.go b/src/runtime/crash_unix_test.go index 4be4962f90..93cee350d0 100644 --- a/src/runtime/crash_unix_test.go +++ b/src/runtime/crash_unix_test.go @@ -16,6 +16,7 @@ import ( "path/filepath" "runtime" "strings" + "sync" "syscall" "testing" "unsafe" @@ -309,3 +310,26 @@ func TestSignalDuringExec(t *testing.T) { t.Fatalf("want %s, got %s\n", want, output) } } + +func TestSignalM(t *testing.T) { + var want, got int64 + var wg sync.WaitGroup + ready := make(chan *runtime.M) + wg.Add(1) + go func() { + runtime.LockOSThread() + want, got = runtime.WaitForSigusr1(func(mp *runtime.M) { + ready <- mp + }, 1e9) + runtime.UnlockOSThread() + wg.Done() + }() + waitingM := <-ready + runtime.SendSigusr1(waitingM) + wg.Wait() + if got == -1 { + t.Fatal("signalM signal not received") + } else if want != got { + t.Fatalf("signal sent to M %d, but received on M %d", want, got) + } +} diff --git a/src/runtime/preemptm_test.go b/src/runtime/preemptm_test.go deleted file mode 100644 index 70c6ad55cb..0000000000 --- a/src/runtime/preemptm_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris - -package runtime_test - -import ( - "runtime" - "sync" - "testing" -) - -func TestPreemptM(t *testing.T) { - var want, got int64 - var wg sync.WaitGroup - ready := make(chan *runtime.M) - wg.Add(1) - go func() { - runtime.LockOSThread() - want, got = runtime.WaitForSigusr1(func(mp *runtime.M) { - ready <- mp - }, 1e9) - runtime.UnlockOSThread() - wg.Done() - }() - runtime.SendSigusr1(<-ready) - wg.Wait() - if got == -1 { - t.Fatal("preemptM signal not received") - } else if want != got { - t.Fatalf("signal sent to M %d, but received on M %d", want, got) - } -} -- 2.50.0