1
0
mirror of https://github.com/golang/go synced 2024-11-18 12:24:48 -07:00

testing: make parsing of -cpu more lenient

Also add \n to error message.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12261044
This commit is contained in:
Russ Cox 2013-08-02 13:51:45 -04:00
parent ebc5513be6
commit 337407d847

View File

@ -575,16 +575,19 @@ func stopAlarm() {
} }
func parseCpuList() { func parseCpuList() {
if len(*cpuListStr) == 0 {
cpuList = append(cpuList, runtime.GOMAXPROCS(-1))
} else {
for _, val := range strings.Split(*cpuListStr, ",") { for _, val := range strings.Split(*cpuListStr, ",") {
val = strings.TrimSpace(val)
if val == "" {
continue
}
cpu, err := strconv.Atoi(val) cpu, err := strconv.Atoi(val)
if err != nil || cpu <= 0 { if err != nil || cpu <= 0 {
fmt.Fprintf(os.Stderr, "testing: invalid value %q for -test.cpu", val) fmt.Fprintf(os.Stderr, "testing: invalid value %q for -test.cpu\n", val)
os.Exit(1) os.Exit(1)
} }
cpuList = append(cpuList, cpu) cpuList = append(cpuList, cpu)
} }
if cpuList == nil {
cpuList = append(cpuList, runtime.GOMAXPROCS(-1))
} }
} }