-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from fromanirh/pci-expose-numa-node
pci: report NUMA node locality for the PCI devices
- Loading branch information
Showing
5 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// Use and distribution licensed under the Apache license version 2. | ||
// | ||
// See the COPYING file in the root project directory for full text. | ||
// | ||
|
||
package pci_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/jaypipes/ghw/pkg/option" | ||
"github.com/jaypipes/ghw/pkg/pci" | ||
|
||
"github.com/jaypipes/ghw/testdata" | ||
) | ||
|
||
type pciNumaTestCase struct { | ||
addr string | ||
node int | ||
} | ||
|
||
// nolint: gocyclo | ||
func TestPCINUMANode(t *testing.T) { | ||
if _, ok := os.LookupEnv("GHW_TESTING_SKIP_PCI"); ok { | ||
t.Skip("Skipping PCI tests.") | ||
} | ||
|
||
testdataPath, err := testdata.SnapshotsDirectory() | ||
if err != nil { | ||
t.Fatalf("Expected nil err, but got %v", err) | ||
} | ||
|
||
multiNumaSnapshot := filepath.Join(testdataPath, "linux-amd64-intel-xeon-L5640.tar.gz") | ||
// from now on we use constants reflecting the content of the snapshot we requested, | ||
// which we reviewed beforehand. IOW, you need to know the content of the | ||
// snapshot to fully understand this test. Inspect it using | ||
// GHW_SNAPSHOT_PATH="/path/to/linux-amd64-intel-xeon-L5640.tar.gz" ghwc topology | ||
|
||
info, err := pci.New(option.WithSnapshot(option.SnapshotOptions{ | ||
Path: multiNumaSnapshot, | ||
})) | ||
|
||
if err != nil { | ||
t.Fatalf("Expected nil err, but got %v", err) | ||
} | ||
if info == nil { | ||
t.Fatalf("Expected non-nil PCIInfo, but got nil") | ||
} | ||
|
||
tCases := []pciNumaTestCase{ | ||
{ | ||
addr: "0000:07:03.0", | ||
// -1 is actually what we get out of the box on the snapshotted box | ||
node: -1, | ||
}, | ||
{ | ||
addr: "0000:05:11.0", | ||
node: 0, | ||
}, | ||
{ | ||
addr: "0000:05:00.1", | ||
node: 1, | ||
}, | ||
} | ||
for _, tCase := range tCases { | ||
t.Run(fmt.Sprintf("%s (%d)", tCase.addr, tCase.node), func(t *testing.T) { | ||
dev := info.GetDevice(tCase.addr) | ||
if dev == nil { | ||
t.Fatalf("got nil device for address %q", tCase.addr) | ||
} | ||
if dev.Node == nil { | ||
if tCase.node != -1 { | ||
t.Fatalf("got nil numa NODE for address %q", tCase.addr) | ||
} | ||
} else { | ||
if dev.Node.ID != tCase.node { | ||
t.Errorf("got NUMA node info %#v, expected on node %d", dev.Node, tCase.node) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+11.9 KB
(140%)
testdata/snapshots/linux-amd64-8581cf3a529e5d8b97ea876eade2f60d.tar.gz
Binary file not shown.