mirror of
https://github.com/golang/go
synced 2024-11-27 04:41:33 -07:00
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: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
b6bdf4587f
commit
28a15e3df3
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user