mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Fix mode resolution tests
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
e30fd0f4ad
commit
fcb4e379e3
@ -28,9 +28,10 @@ func TestResolveMode(t *testing.T) {
|
|||||||
logger, _ := testlog.NewNullLogger()
|
logger, _ := testlog.NewNullLogger()
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
mode string
|
mode string
|
||||||
// TODO: This should be a proper mock
|
isTegra bool
|
||||||
hasDXCore bool
|
hasDXCore bool
|
||||||
|
hasNVML bool
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -41,11 +42,34 @@ func TestResolveMode(t *testing.T) {
|
|||||||
{
|
{
|
||||||
mode: "auto",
|
mode: "auto",
|
||||||
hasDXCore: false,
|
hasDXCore: false,
|
||||||
|
isTegra: true,
|
||||||
|
hasNVML: false,
|
||||||
|
expected: "csv",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mode: "auto",
|
||||||
|
hasDXCore: false,
|
||||||
|
isTegra: false,
|
||||||
|
hasNVML: false,
|
||||||
|
expected: "nvml",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mode: "auto",
|
||||||
|
hasDXCore: false,
|
||||||
|
isTegra: true,
|
||||||
|
hasNVML: true,
|
||||||
|
expected: "nvml",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mode: "auto",
|
||||||
|
hasDXCore: false,
|
||||||
|
isTegra: false,
|
||||||
expected: "nvml",
|
expected: "nvml",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
mode: "nvml",
|
mode: "nvml",
|
||||||
hasDXCore: true,
|
hasDXCore: true,
|
||||||
|
isTegra: true,
|
||||||
expected: "nvml",
|
expected: "nvml",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -65,7 +89,7 @@ func TestResolveMode(t *testing.T) {
|
|||||||
l := nvcdilib{
|
l := nvcdilib{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
mode: tc.mode,
|
mode: tc.mode,
|
||||||
infolib: infoMock(tc.hasDXCore),
|
infolib: infoMock{hasDXCore: tc.hasDXCore, isTegra: tc.isTegra, hasNVML: tc.hasNVML},
|
||||||
}
|
}
|
||||||
|
|
||||||
require.Equal(t, tc.expected, l.resolveMode())
|
require.Equal(t, tc.expected, l.resolveMode())
|
||||||
@ -73,16 +97,20 @@ func TestResolveMode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type infoMock bool
|
type infoMock struct {
|
||||||
|
hasDXCore bool
|
||||||
|
isTegra bool
|
||||||
|
hasNVML bool
|
||||||
|
}
|
||||||
|
|
||||||
func (i infoMock) HasDXCore() (bool, string) {
|
func (i infoMock) HasDXCore() (bool, string) {
|
||||||
return bool(i), ""
|
return bool(i.hasDXCore), ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i infoMock) HasNvml() (bool, string) {
|
func (i infoMock) HasNvml() (bool, string) {
|
||||||
panic("should not be called")
|
return bool(i.hasNVML), ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i infoMock) IsTegraSystem() (bool, string) {
|
func (i infoMock) IsTegraSystem() (bool, string) {
|
||||||
panic("should not be called")
|
return bool(i.isTegra), ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user