MXL Fabrics tests
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
//go:build mxl_integration
|
||||
|
||||
package mxlfabrics_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/qvest-digital/go-mxl/fabrics"
|
||||
"github.com/qvest-digital/go-mxl/mxl"
|
||||
)
|
||||
|
||||
func requireSHMInterface(
|
||||
t *testing.T,
|
||||
instance *fabrics.Instance,
|
||||
) fabrics.InterfaceConfig {
|
||||
t.Helper()
|
||||
|
||||
interfaces, err := instance.Interfaces(&fabrics.InterfaceConfig{
|
||||
Provider: fabrics.ProviderSHM,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("enumerate SHM interfaces: %v", err)
|
||||
}
|
||||
|
||||
for _, iface := range interfaces {
|
||||
if iface.Provider != fabrics.ProviderSHM {
|
||||
continue
|
||||
}
|
||||
if iface.Caps.Flags&fabrics.InterfaceCapRemoteWrite == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// Allow libfabric to assign a unique local SHM endpoint during
|
||||
// Target.Setup or Initiator.Setup. The enumerated service is
|
||||
// descriptive and should not be reused by both endpoints.
|
||||
iface.Address.Service = ""
|
||||
return iface
|
||||
}
|
||||
|
||||
t.Fatal("no remote-write-capable SHM Fabrics interface found")
|
||||
return fabrics.InterfaceConfig{}
|
||||
}
|
||||
|
||||
func TestInterfacesIncludesSHM(t *testing.T) {
|
||||
if _, err := os.Stat("/dev/shm"); err != nil {
|
||||
t.Skipf("/dev/shm is unavailable: %v", err)
|
||||
}
|
||||
|
||||
domain, err := os.MkdirTemp("/dev/shm", "mxl-player-fabrics-*")
|
||||
if err != nil {
|
||||
t.Fatalf("create temporary MXL domain: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if err := os.RemoveAll(domain); err != nil {
|
||||
t.Errorf("remove temporary MXL domain: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
instance, err := mxl.NewInstance(domain, "")
|
||||
if err != nil {
|
||||
t.Fatalf("create MXL instance: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if err := instance.Close(); err != nil {
|
||||
t.Errorf("close MXL instance: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
fabricInstance, err := fabrics.NewInstance(instance)
|
||||
if err != nil {
|
||||
t.Fatalf("create Fabrics instance: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if err := fabricInstance.Close(); err != nil {
|
||||
t.Errorf("close Fabrics instance: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
iface := requireSHMInterface(t, fabricInstance)
|
||||
|
||||
t.Logf(
|
||||
"SHM interface: node=%q flags=%#x max-message-size=%d attr=%q",
|
||||
iface.Address.Node,
|
||||
iface.Caps.Flags,
|
||||
iface.Caps.MaxMessageSize,
|
||||
iface.Attr,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user