Commit 28a15e3d authored by Austin Clements's avatar Austin Clements

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 <austin@google.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent b6bdf458
......@@ -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)
}
}
// 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)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment