diff options
author | Steven Hartland <steven.hartland@multiplay.co.uk> | 2020-05-07 22:34:25 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-05-08 20:24:33 +0000 |
commit | 8f4be42b37469d7c392c330ac13599a88d5c9ea2 (patch) | |
tree | df37d904cc1b62e2f3032d4a4dd4384983e81735 /src/runtime/testdata | |
parent | 4f65fb3b309050f26d41885243df99f917727a53 (diff) | |
download | go-8f4be42b37469d7c392c330ac13599a88d5c9ea2.tar.gz go-8f4be42b37469d7c392c330ac13599a88d5c9ea2.zip |
runtime: use first line of cpuset output on FreeBSD
Fix TestFreeBSDNumCPU on newer versions of FreeBSD which have multi line
output from cpuset e.g.
cpuset -g -p 4141
pid 4141 mask: 0, 1, 2, 3, 4, 5, 6, 7, 8
pid 4141 domain policy: first-touch mask: 0, 1
The test now uses just the first line of output.
Fixes #38937
Fixes #25924
Change-Id: If082ee6b82120ebde4dc437e58343b3dad69c65f
Reviewed-on: https://go-review.googlesource.com/c/go/+/232801
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r-- | src/runtime/testdata/testprog/numcpu_freebsd.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/runtime/testdata/testprog/numcpu_freebsd.go b/src/runtime/testdata/testprog/numcpu_freebsd.go index 42ee154883..aff36ec702 100644 --- a/src/runtime/testdata/testprog/numcpu_freebsd.go +++ b/src/runtime/testdata/testprog/numcpu_freebsd.go @@ -85,7 +85,13 @@ func getList() ([]string, error) { if err != nil { return nil, fmt.Errorf("fail to execute '%s': %s", cmdline, err) } - pos := bytes.IndexRune(output, ':') + pos := bytes.IndexRune(output, '\n') + if pos == -1 { + return nil, fmt.Errorf("invalid output from '%s', '\\n' not found: %s", cmdline, output) + } + output = output[0:pos] + + pos = bytes.IndexRune(output, ':') if pos == -1 { return nil, fmt.Errorf("invalid output from '%s', ':' not found: %s", cmdline, output) } |