-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pci: report NUMA node locality for the PCI devices #225
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍