]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: rename TestPreemptM to TestSignalM
authorAustin Clements <austin@google.com>
Tue, 29 Oct 2019 02:19:32 +0000 (22:19 -0400)
committerAustin Clements <austin@google.com>
Tue, 29 Oct 2019 13:46:23 +0000 (13:46 +0000)
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>

src/runtime/crash_unix_test.go
src/runtime/preemptm_test.go [deleted file]

index 4be4962f907cf64aa60162c1bea8b3ecb78710ad..93cee350d0018e7e4b3dbbe2d852c37cb3dc34ec 100644 (file)
@@ -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 (file)
index 70c6ad5..0000000
+++ /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)
-       }
-}