gpu_test.go 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package gpu
  2. import (
  3. "runtime"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestBasicGetGPUInfo(t *testing.T) {
  8. info := GetGPUInfo()
  9. assert.Contains(t, "cuda rocm cpu metal", info.Library)
  10. switch runtime.GOOS {
  11. case "darwin":
  12. // TODO - remove this once MacOS returns some size for CPU
  13. return
  14. case "linux", "windows":
  15. assert.Greater(t, info.TotalMemory, uint64(0))
  16. assert.Greater(t, info.FreeMemory, uint64(0))
  17. assert.Greater(t, info.DeviceCount, uint32(0))
  18. default:
  19. return
  20. }
  21. }
  22. func TestCPUMemInfo(t *testing.T) {
  23. info, err := getCPUMem()
  24. assert.NoError(t, err)
  25. switch runtime.GOOS {
  26. case "darwin":
  27. t.Skip("CPU memory not populated on darwin")
  28. case "linux", "windows":
  29. assert.Greater(t, info.TotalMemory, uint64(0))
  30. assert.Greater(t, info.FreeMemory, uint64(0))
  31. default:
  32. return
  33. }
  34. }
  35. // TODO - add some logic to figure out card type through other means and actually verify we got back what we expected