gpu_test.go 820 B

12345678910111213141516171819202122232425262728293031323334
  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.Greater(t, len(info), 0)
  10. assert.Contains(t, "cuda rocm cpu metal", info[0].Library)
  11. if info[0].Library != "cpu" {
  12. assert.Greater(t, info[0].TotalMemory, uint64(0))
  13. assert.Greater(t, info[0].FreeMemory, uint64(0))
  14. }
  15. }
  16. func TestCPUMemInfo(t *testing.T) {
  17. info, err := GetCPUMem()
  18. assert.NoError(t, err)
  19. switch runtime.GOOS {
  20. case "darwin":
  21. t.Skip("CPU memory not populated on darwin")
  22. case "linux", "windows":
  23. assert.Greater(t, info.TotalMemory, uint64(0))
  24. assert.Greater(t, info.FreeMemory, uint64(0))
  25. default:
  26. return
  27. }
  28. }
  29. // TODO - add some logic to figure out card type through other means and actually verify we got back what we expected