2023-11-29 19:00:37 +00:00
|
|
|
package gpu
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBasicGetGPUInfo(t *testing.T) {
|
|
|
|
info := GetGPUInfo()
|
2024-01-10 04:29:58 +00:00
|
|
|
assert.Contains(t, "cuda rocm cpu metal", info.Library)
|
2023-11-29 19:00:37 +00:00
|
|
|
|
|
|
|
switch runtime.GOOS {
|
|
|
|
case "darwin":
|
|
|
|
// TODO - remove this once MacOS returns some size for CPU
|
|
|
|
return
|
|
|
|
case "linux", "windows":
|
|
|
|
assert.Greater(t, info.TotalMemory, uint64(0))
|
|
|
|
assert.Greater(t, info.FreeMemory, uint64(0))
|
2024-01-11 13:22:23 +00:00
|
|
|
assert.Greater(t, info.DeviceCount, uint32(0))
|
2023-11-29 19:00:37 +00:00
|
|
|
default:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-22 23:43:31 +00:00
|
|
|
func TestCPUMemInfo(t *testing.T) {
|
|
|
|
info, err := getCPUMem()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
switch runtime.GOOS {
|
|
|
|
case "darwin":
|
|
|
|
t.Skip("CPU memory not populated on darwin")
|
|
|
|
case "linux", "windows":
|
|
|
|
assert.Greater(t, info.TotalMemory, uint64(0))
|
|
|
|
assert.Greater(t, info.FreeMemory, uint64(0))
|
|
|
|
default:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-29 19:00:37 +00:00
|
|
|
// TODO - add some logic to figure out card type through other means and actually verify we got back what we expected
|