diff options
author | Dave Cheney <dave@cheney.net> | 2013-01-12 17:52:52 +1100 |
---|---|---|
committer | Dave Cheney <dave@cheney.net> | 2013-01-12 17:52:52 +1100 |
commit | e0521776264d97fee7f06e1e49fb1209893d0b0c (patch) | |
tree | 8f515d4b21cf1d952827e2d79f4203176926ac79 /test | |
parent | ba2259dd577b9e9956f3ec57c55f8a7a36350a19 (diff) | |
download | go-e0521776264d97fee7f06e1e49fb1209893d0b0c.tar.gz |
test: limit runoutput tests on arm platforms
runoutput styles tests generally consume a lot of memory. On arm platforms rotate?.go consume around 200mb each to compile, and as tests are sorted alphabetically, they all tend to run at once.
This change limits the number of runoutput jobs to 2 on arm platforms.
R=minux.ma, remyoudompheng, bradfitz, lucio.dere
CC=golang-dev
https://codereview.appspot.com/7099047
Diffstat (limited to 'test')
-rw-r--r-- | test/run.go | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/test/run.go b/test/run.go index c7305d30b..fb528fa4c 100644 --- a/test/run.go +++ b/test/run.go @@ -30,10 +30,11 @@ import ( ) var ( - verbose = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.") - numParallel = flag.Int("n", runtime.NumCPU(), "number of parallel tests to run") - summary = flag.Bool("summary", false, "show summary of results") - showSkips = flag.Bool("show_skips", false, "show skipped tests") + verbose = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.") + numParallel = flag.Int("n", runtime.NumCPU(), "number of parallel tests to run") + summary = flag.Bool("summary", false, "show summary of results") + showSkips = flag.Bool("show_skips", false, "show skipped tests") + runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run") ) var ( @@ -53,6 +54,10 @@ var ( // toRun is the channel of tests to run. // It is nil until the first test is started. toRun chan *test + + // rungatec controls the max number of runoutput tests + // executed in parallel as they can each consume a lot of memory. + rungatec chan bool ) // maxTests is an upper bound on the total number of tests. @@ -68,6 +73,7 @@ func main() { } ratec = make(chan bool, *numParallel) + rungatec = make(chan bool, *runoutputLimit) var err error letter, err = build.ArchChar(build.Default.GOARCH) check(err) @@ -504,14 +510,17 @@ func (t *test) run() { } case "runoutput": + rungatec <- true + defer func() { + <-rungatec + }() useTmp = false out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) if err != nil { t.err = err } tfile := filepath.Join(t.tempDir, "tmp__.go") - err = ioutil.WriteFile(tfile, out, 0666) - if err != nil { + if err := ioutil.WriteFile(tfile, out, 0666); err != nil { t.err = fmt.Errorf("write tempfile:%s", err) return } @@ -735,3 +744,15 @@ var skipOkay = map[string]bool{ "fixedbugs/bug429.go": true, "bugs/bug395.go": true, } + +// defaultRunOutputLimit returns the number of runoutput tests that +// can be executed in parallel. +func defaultRunOutputLimit() int { + const maxArmCPU = 2 + + cpu := runtime.NumCPU() + if runtime.GOARCH == "arm" && cpu > maxArmCPU { + cpu = maxArmCPU + } + return cpu +} |