Commit c2ed4eda authored by Lynn Boger's avatar Lynn Boger

unix: fix TestSchedSetaffinity for smt settings

If a system has the ability to disable some cores, as on
ppc64 with the ppc64_cpu command, then TestSchedSetaffinity will
fail if the CPUset passed to Setaffinity includes one that has
been disabled.

This adds a check to use values from the oldMask, which are the valid
cores returned from Getaffinity, to pass to Setaffinity.

Fixes golang/go#27875

Change-Id: I9656f41867afc18e0eaedc4bdef5f75e137a1fcd
Reviewed-on: https://go-review.googlesource.com/137675Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 2f1df4e5
......@@ -273,6 +273,23 @@ func TestSchedSetaffinity(t *testing.T) {
t.Skip("skipping setaffinity tests on android")
}
// On a system like ppc64x where some cores can be disabled using ppc64_cpu,
// setaffinity should only be called with enabled cores. The valid cores
// are found from the oldMask, but if none are found then the setaffinity
// tests are skipped. Issue #27875.
if !oldMask.IsSet(cpu) {
newMask.Zero()
for i := 0; i < len(oldMask); i++ {
if oldMask.IsSet(i) {
newMask.Set(i)
break
}
}
if newMask.Count() == 0 {
t.Skip("skipping setaffinity tests if CPU not available")
}
}
err = unix.SchedSetaffinity(0, &newMask)
if err != nil {
t.Fatalf("SchedSetaffinity: %v", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment