mirror of
https://github.com/golang/go
synced 2024-11-19 16:04:48 -07:00
e19f184b8f
In FreeBSD when run Go proc under a given sub-list of processors(e.g. 'cpuset -l 0 ./a.out' in multi-core system), runtime.NumCPU() still return all physical CPUs from sysctl hw.ncpu instead of account from sub-list. Fix by use syscall cpuset_getaffinity to account the number of sub-list. Fixes #15206 Change-Id: If87c4b620e870486efa100685db5debbf1210a5b Reviewed-on: https://go-review.googlesource.com/29341 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
16 lines
381 B
Go
16 lines
381 B
Go
// Copyright 2017 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package runtime_test
|
|
|
|
import "testing"
|
|
|
|
func TestFreeBSDNumCPU(t *testing.T) {
|
|
got := runTestProg(t, "testprog", "FreeBSDNumCPU")
|
|
want := "OK\n"
|
|
if got != want {
|
|
t.Fatalf("expected %q, but got:\n%s", want, got)
|
|
}
|
|
}
|