mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: move test programs out of source code, coalesce
Now there are just three programs to compile instead of many, and repeated tests can reuse the compilation result instead of rebuilding it. Combined, these changes reduce the time spent testing runtime during all.bash on my laptop from about 60 to about 30 seconds. (All.bash itself runs in 5½ minutes.) For #10571. Change-Id: Ie2c1798b847f1a635a860d11dcdab14375319ae9 Reviewed-on: https://go-review.googlesource.com/18085 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com>
This commit is contained in:
parent
a699320512
commit
8d5ff2e182
24 changed files with 994 additions and 820 deletions
|
|
@ -329,48 +329,13 @@ func TestPreemptionGC(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGCFairness(t *testing.T) {
|
||||
output := executeTest(t, testGCFairnessSource, nil)
|
||||
output := runTestProg(t, "testprog", "GCFairness")
|
||||
want := "OK\n"
|
||||
if output != want {
|
||||
t.Fatalf("want %s, got %s\n", want, output)
|
||||
}
|
||||
}
|
||||
|
||||
const testGCFairnessSource = `
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(1)
|
||||
f, err := os.Open("/dev/null")
|
||||
if os.IsNotExist(err) {
|
||||
// This test tests what it is intended to test only if writes are fast.
|
||||
// If there is no /dev/null, we just don't execute the test.
|
||||
fmt.Println("OK")
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
for i := 0; i < 2; i++ {
|
||||
go func() {
|
||||
for {
|
||||
f.Write([]byte("."))
|
||||
}
|
||||
}()
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
fmt.Println("OK")
|
||||
}
|
||||
`
|
||||
|
||||
func TestPingPongHog(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping in -short mode")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue