sysresources_test.go 481 B

12345678910111213141516171819202122232425
  1. // Copyright (c) Tailscale Inc & contributors
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package sysresources
  4. import (
  5. "runtime"
  6. "testing"
  7. )
  8. func TestTotalMemory(t *testing.T) {
  9. switch runtime.GOOS {
  10. case "linux":
  11. case "freebsd", "openbsd", "dragonfly", "netbsd":
  12. case "darwin":
  13. default:
  14. t.Skipf("not supported on runtime.GOOS=%q yet", runtime.GOOS)
  15. }
  16. mem := TotalMemory()
  17. if mem == 0 {
  18. t.Fatal("wanted TotalMemory > 0")
  19. }
  20. t.Logf("total memory: %v bytes", mem)
  21. }