|
|
|
@ -9,6 +9,12 @@ import (
|
|
|
|
|
"github.com/shirou/gopsutil/internal/common"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func skipIfNotImplementedErr(t *testing.T, err error) {
|
|
|
|
|
if err == common.ErrNotImplementedError {
|
|
|
|
|
t.Skip("not implemented")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAddrString(t *testing.T) {
|
|
|
|
|
v := Addr{IP: "192.168.0.1", Port: 8000}
|
|
|
|
|
|
|
|
|
@ -61,10 +67,12 @@ func TestNetConnectionStatString(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestNetIOCountersAll(t *testing.T) {
|
|
|
|
|
v, err := IOCounters(false)
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("Could not get NetIOCounters: %v", err)
|
|
|
|
|
}
|
|
|
|
|
per, err := IOCounters(true)
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("Could not get NetIOCounters: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -85,6 +93,7 @@ func TestNetIOCountersAll(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestNetIOCountersPerNic(t *testing.T) {
|
|
|
|
|
v, err := IOCounters(true)
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("Could not get NetIOCounters: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -113,6 +122,7 @@ func TestGetNetIOCountersAll(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
ret, err := getIOCountersAll(n)
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error(err)
|
|
|
|
|
}
|
|
|
|
@ -132,6 +142,7 @@ func TestGetNetIOCountersAll(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestNetInterfaces(t *testing.T) {
|
|
|
|
|
v, err := Interfaces()
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("Could not get NetInterfaceStat: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -147,6 +158,7 @@ func TestNetInterfaces(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestNetProtoCountersStatsAll(t *testing.T) {
|
|
|
|
|
v, err := ProtoCounters(nil)
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Could not get NetProtoCounters: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -165,6 +177,7 @@ func TestNetProtoCountersStatsAll(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestNetProtoCountersStats(t *testing.T) {
|
|
|
|
|
v, err := ProtoCounters([]string{"tcp", "ip"})
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Could not get NetProtoCounters: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -190,6 +203,7 @@ func TestNetConnections(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v, err := Connections("inet")
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("could not get NetConnections: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -217,6 +231,7 @@ func TestNetFilterCounters(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v, err := FilterCounters()
|
|
|
|
|
skipIfNotImplementedErr(t, err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("could not get NetConnections: %v", err)
|
|
|
|
|
}
|
|
|
|
|