cpu_test.go 489 字节
Newer Older
1
package gopsutil
W
WAKAYAMA Shirou 已提交
2 3 4 5 6 7

import (
	"testing"
)

func TestCpu_times(t *testing.T) {
8
	v, err := Cpu_times(false)
W
WAKAYAMA Shirou 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
	if err != nil {
		t.Errorf("error %v", err)
	}
	if len(v) == 0 {
		t.Errorf("could not get CPUs ", err)
	}

	for _, vv := range v {
		if vv.User == 0 {
			t.Errorf("could not get CPU User: %v", vv)
		}
	}
}

func TestCpu_counts(t *testing.T) {
24
	v, err := Cpu_counts(true)
W
WAKAYAMA Shirou 已提交
25 26 27 28 29 30 31
	if err != nil {
		t.Errorf("error %v", err)
	}
	if v == 0 {
		t.Errorf("could not get CPU counts: %v", v)
	}
}