github.com/lrita/numa@v1.0.2/numa_linux_test.go (about) 1 package numa 2 3 import ( 4 "fmt" 5 "strings" 6 "testing" 7 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestCPUAndNodeShow(t *testing.T) { 12 var ( 13 assert = require.New(t) 14 slice = map[int][]string{} 15 nmask = NodeMask() 16 ) 17 18 for i := 0; i < nmask.Len(); i++ { 19 if !nmask.Get(i) { 20 continue 21 } 22 var cpu []string 23 m, err := NodeToCPUMask(i) 24 assert.NoError(err, "node %d", i) 25 for j := 0; j < m.Len(); j++ { 26 if m.Get(j) { 27 cpu = append(cpu, fmt.Sprint(j)) 28 } 29 } 30 slice[i] = cpu 31 } 32 33 for node, cpu := range slice { 34 t.Log(fmt.Sprintf("node %d cpus: %s", node, strings.Join(cpu, " "))) 35 } 36 }