aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/semasleep_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2019-05-15 20:49:39 -0400
committerRuss Cox <rsc@golang.org>2019-05-22 12:54:00 +0000
commit06b0babf3138d189f6e741561f77ac6146696377 (patch)
tree04cda16449e7f9dfdd9e14926ef78e4e0d61be78 /src/runtime/semasleep_test.go
parentb0e238add5dc8ab80b4eade78ca047f074658dcd (diff)
downloadgo-06b0babf3138d189f6e741561f77ac6146696377.tar.gz
go-06b0babf3138d189f6e741561f77ac6146696377.zip
all: shorten some tests
Shorten some of the longest tests that run during all.bash. Removes 7r 50u 21s from all.bash. After this change, all.bash is under 5 minutes again on my laptop. For #26473. Change-Id: Ie0460aa935808d65460408feaed210fbaa1d5d79 Reviewed-on: https://go-review.googlesource.com/c/go/+/177559 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/semasleep_test.go')
-rw-r--r--src/runtime/semasleep_test.go40
1 files changed, 7 insertions, 33 deletions
diff --git a/src/runtime/semasleep_test.go b/src/runtime/semasleep_test.go
index b931095619..f5b4a50697 100644
--- a/src/runtime/semasleep_test.go
+++ b/src/runtime/semasleep_test.go
@@ -7,11 +7,7 @@
package runtime_test
import (
- "internal/testenv"
- "io/ioutil"
- "os"
"os/exec"
- "path/filepath"
"syscall"
"testing"
"time"
@@ -24,39 +20,14 @@ func TestSpuriousWakeupsNeverHangSemasleep(t *testing.T) {
if *flagQuick {
t.Skip("-quick")
}
- testenv.MustHaveGoBuild(t)
- tempDir, err := ioutil.TempDir("", "issue-27250")
- if err != nil {
- t.Fatalf("Failed to create the temp directory: %v", err)
- }
- defer os.RemoveAll(tempDir)
-
- repro := `
- package main
-
- import "time"
- func main() {
- <-time.After(1 * time.Second)
- }
- `
- mainPath := filepath.Join(tempDir, "main.go")
- if err := ioutil.WriteFile(mainPath, []byte(repro), 0644); err != nil {
- t.Fatalf("Failed to create temp file for repro.go: %v", err)
- }
- binaryPath := filepath.Join(tempDir, "binary")
-
- // Build the binary so that we can send the signal to its PID.
- out, err := exec.Command(testenv.GoToolPath(t), "build", "-o", binaryPath, mainPath).CombinedOutput()
+ exe, err := buildTestProg(t, "testprog")
if err != nil {
- t.Fatalf("Failed to compile the binary: err: %v\nOutput: %s\n", err, out)
- }
- if err := os.Chmod(binaryPath, 0755); err != nil {
- t.Fatalf("Failed to chmod binary: %v", err)
+ t.Fatal(err)
}
- // Now run the binary.
- cmd := exec.Command(binaryPath)
+ start := time.Now()
+ cmd := exec.Command(exe, "After1")
if err := cmd.Start(); err != nil {
t.Fatalf("Failed to start command: %v", err)
}
@@ -85,6 +56,9 @@ func TestSpuriousWakeupsNeverHangSemasleep(t *testing.T) {
if err != nil {
t.Fatalf("The program returned but unfortunately with an error: %v", err)
}
+ if time.Since(start) < 100*time.Millisecond {
+ t.Fatalf("The program stopped too quickly.")
+ }
return
}
}