1
0
mirror of https://github.com/golang/go synced 2024-11-06 09:16:16 -07:00
go/src/runtime/numcpu_freebsd_test.go
David NewHamlet e19f184b8f runtime: use cpuset_getaffinity for runtime.NumCPU() on FreeBSD
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>
2017-03-10 22:06:24 +00:00

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)
}
}