diff --git a/cpu_test.go b/test/cpu_test.go similarity index 82% rename from cpu_test.go rename to test/cpu_test.go index 15b6705..2eeaea7 100644 --- a/cpu_test.go +++ b/test/cpu_test.go @@ -1,19 +1,21 @@ -package gopsutil +package test import ( "fmt" "testing" + + "github.com/shirou/gopsutil" ) func TestCpu_times(t *testing.T) { - v, err := CPUTimes(false) + v, err := gopsutil.CPUTimes(false) if err != nil { t.Errorf("error %v", err) } if len(v) == 0 { t.Errorf("could not get CPUs ", err) } - empty := CPUTimesStat{} + empty := gopsutil.CPUTimesStat{} for _, vv := range v { if vv == empty { t.Errorf("could not get CPU User: %v", vv) @@ -22,7 +24,7 @@ func TestCpu_times(t *testing.T) { } func TestCpu_counts(t *testing.T) { - v, err := CPUCounts(true) + v, err := gopsutil.CPUCounts(true) if err != nil { t.Errorf("error %v", err) } @@ -32,7 +34,7 @@ func TestCpu_counts(t *testing.T) { } func TestCPUTimeStat_String(t *testing.T) { - v := CPUTimesStat{ + v := gopsutil.CPUTimesStat{ CPU: "cpu0", User: 100.1, System: 200.1, @@ -45,7 +47,7 @@ func TestCPUTimeStat_String(t *testing.T) { } func TestCpuInfo(t *testing.T) { - v, err := CPUInfo() + v, err := gopsutil.CPUInfo() if err != nil { t.Errorf("error %v", err) } diff --git a/disk_test.go b/test/disk_test.go similarity index 82% rename from disk_test.go rename to test/disk_test.go index 06d7d50..dd9a836 100644 --- a/disk_test.go +++ b/test/disk_test.go @@ -1,9 +1,11 @@ -package gopsutil +package test import ( "fmt" "runtime" "testing" + + "github.com/shirou/gopsutil" ) func TestDisk_usage(t *testing.T) { @@ -11,7 +13,7 @@ func TestDisk_usage(t *testing.T) { if runtime.GOOS == "windows" { path = "C:" } - v, err := DiskUsage(path) + v, err := gopsutil.DiskUsage(path) if err != nil { t.Errorf("error %v", err) } @@ -21,11 +23,11 @@ func TestDisk_usage(t *testing.T) { } func TestDisk_partitions(t *testing.T) { - ret, err := DiskPartitions(false) + ret, err := gopsutil.DiskPartitions(false) if err != nil { t.Errorf("error %v", err) } - empty := DiskPartitionStat{} + empty := gopsutil.DiskPartitionStat{} for _, disk := range ret { if disk == empty { t.Errorf("Could not get device info %v", disk) @@ -34,11 +36,11 @@ func TestDisk_partitions(t *testing.T) { } func TestDisk_io_counters(t *testing.T) { - ret, err := DiskIOCounters() + ret, err := gopsutil.DiskIOCounters() if err != nil { t.Errorf("error %v", err) } - empty := DiskIOCountersStat{} + empty := gopsutil.DiskIOCountersStat{} for _, io := range ret { if io == empty { t.Errorf("io_counter error %v", io) @@ -47,7 +49,7 @@ func TestDisk_io_counters(t *testing.T) { } func TestDiskUsageStat_String(t *testing.T) { - v := DiskUsageStat{ + v := gopsutil.DiskUsageStat{ Path: "/", Total: 1000, Free: 2000, @@ -61,7 +63,7 @@ func TestDiskUsageStat_String(t *testing.T) { } func TestDiskPartitionStat_String(t *testing.T) { - v := DiskPartitionStat{ + v := gopsutil.DiskPartitionStat{ Device: "sd01", Mountpoint: "/", Fstype: "ext4", @@ -74,7 +76,7 @@ func TestDiskPartitionStat_String(t *testing.T) { } func TestDiskIOCountersStat_String(t *testing.T) { - v := DiskIOCountersStat{ + v := gopsutil.DiskIOCountersStat{ Name: "sd01", ReadCount: 100, WriteCount: 200, diff --git a/host_test.go b/test/host_test.go similarity index 81% rename from host_test.go rename to test/host_test.go index fbf73bf..3c16631 100644 --- a/host_test.go +++ b/test/host_test.go @@ -1,23 +1,25 @@ -package gopsutil +package test import ( "fmt" "testing" + + "github.com/shirou/gopsutil" ) func TestHostInfo(t *testing.T) { - v, err := HostInfo() + v, err := gopsutil.HostInfo() if err != nil { t.Errorf("error %v", err) } - empty := &HostInfoStat{} + empty := &gopsutil.HostInfoStat{} if v == empty { t.Errorf("Could not get hostinfo %v", v) } } func TestBoot_time(t *testing.T) { - v, err := BootTime() + v, err := gopsutil.BootTime() if err != nil { t.Errorf("error %v", err) } @@ -27,11 +29,11 @@ func TestBoot_time(t *testing.T) { } func TestUsers(t *testing.T) { - v, err := Users() + v, err := gopsutil.Users() if err != nil { t.Errorf("error %v", err) } - empty := UserStat{} + empty := gopsutil.UserStat{} for _, u := range v { if u == empty { t.Errorf("Could not Users %v", v) @@ -40,7 +42,7 @@ func TestUsers(t *testing.T) { } func TestHostInfoStat_String(t *testing.T) { - v := HostInfoStat{ + v := gopsutil.HostInfoStat{ Hostname: "test", Uptime: 3000, Procs: 100, @@ -54,7 +56,7 @@ func TestHostInfoStat_String(t *testing.T) { } func TestUserStat_String(t *testing.T) { - v := UserStat{ + v := gopsutil.UserStat{ User: "user", Terminal: "term", Host: "host", diff --git a/load_test.go b/test/load_test.go similarity index 74% rename from load_test.go rename to test/load_test.go index 41f178a..a3feb61 100644 --- a/load_test.go +++ b/test/load_test.go @@ -1,26 +1,26 @@ -// +build linux - -package gopsutil +package test import ( "fmt" "testing" + + "github.com/shirou/gopsutil" ) func TestLoad(t *testing.T) { - v, err := LoadAvg() + v, err := gopsutil.LoadAvg() if err != nil { t.Errorf("error %v", err) } - empty := &LoadAvgStat{} + empty := &gopsutil.LoadAvgStat{} if v == empty { t.Errorf("error load: %v", v) } } func TestLoadAvgStat_String(t *testing.T) { - v := LoadAvgStat{ + v := gopsutil.LoadAvgStat{ Load1: 10.1, Load5: 20.1, Load15: 30.1, diff --git a/mem_test.go b/test/mem_test.go similarity index 79% rename from mem_test.go rename to test/mem_test.go index 7d66550..163eff8 100644 --- a/mem_test.go +++ b/test/mem_test.go @@ -1,35 +1,37 @@ -package gopsutil +package test import ( "fmt" "testing" + + "github.com/shirou/gopsutil" ) func TestVirtual_memory(t *testing.T) { - v, err := VirtualMemory() + v, err := gopsutil.VirtualMemory() if err != nil { t.Errorf("error %v", err) } - empty := &VirtualMemoryStat{} + empty := &gopsutil.VirtualMemoryStat{} if v == empty { t.Errorf("error %v", v) } } func TestSwap_memory(t *testing.T) { - v, err := SwapMemory() + v, err := gopsutil.SwapMemory() if err != nil { t.Errorf("error %v", err) } - empty := &SwapMemoryStat{} + empty := &gopsutil.SwapMemoryStat{} if v == empty { t.Errorf("error %v", v) } } func TestVirtualMemoryStat_String(t *testing.T) { - v := VirtualMemoryStat{ + v := gopsutil.VirtualMemoryStat{ Total: 10, Available: 20, Used: 30, @@ -43,7 +45,7 @@ func TestVirtualMemoryStat_String(t *testing.T) { } func TestSwapMemoryStat_String(t *testing.T) { - v := SwapMemoryStat{ + v := gopsutil.SwapMemoryStat{ Total: 10, Used: 30, Free: 40, diff --git a/net_test.go b/test/net_test.go similarity index 84% rename from net_test.go rename to test/net_test.go index 6d7fde2..3a25486 100644 --- a/net_test.go +++ b/test/net_test.go @@ -1,12 +1,14 @@ -package gopsutil +package test import ( "fmt" "testing" + + "github.com/shirou/gopsutil" ) func TestAddrString(t *testing.T) { - v := Addr{IP: "192.168.0.1", Port: 8000} + v := gopsutil.Addr{IP: "192.168.0.1", Port: 8000} s := fmt.Sprintf("%v", v) if s != "{\"ip\":\"192.168.0.1\",\"port\":8000}" { @@ -15,7 +17,7 @@ func TestAddrString(t *testing.T) { } func TestNetIOCountersStatString(t *testing.T) { - v := NetIOCountersStat{ + v := gopsutil.NetIOCountersStat{ Name: "test", BytesSent: 100, } @@ -26,7 +28,7 @@ func TestNetIOCountersStatString(t *testing.T) { } func TestNetConnectionStatString(t *testing.T) { - v := NetConnectionStat{ + v := gopsutil.NetConnectionStat{ Fd: 10, Family: 10, Type: 10, @@ -39,7 +41,7 @@ func TestNetConnectionStatString(t *testing.T) { } func TestNetIOCounters(t *testing.T) { - v, err := NetIOCounters(true) + v, err := gopsutil.NetIOCounters(true) if err != nil { t.Errorf("Could not get NetIOCounters: %v", err) } diff --git a/process_posix_test.go b/test/process_posix_test.go similarity index 71% rename from process_posix_test.go rename to test/process_posix_test.go index b45418a..94df7f1 100644 --- a/process_posix_test.go +++ b/test/process_posix_test.go @@ -1,17 +1,19 @@ // +build linux freebsd -package gopsutil +package test import ( "os" "syscall" "testing" + + "github.com/shirou/gopsutil" ) func Test_SendSignal(t *testing.T) { checkPid := os.Getpid() - p, _ := NewProcess(int32(checkPid)) + p, _ := gopsutil.NewProcess(int32(checkPid)) err := p.SendSignal(syscall.SIGCONT) if err != nil { t.Errorf("send signal %v", err) diff --git a/process_test.go b/test/process_test.go similarity index 80% rename from process_test.go rename to test/process_test.go index 6598e28..ce4dfab 100644 --- a/process_test.go +++ b/test/process_test.go @@ -1,22 +1,24 @@ -package gopsutil +package test import ( "os" "runtime" "testing" + + "github.com/shirou/gopsutil" ) -func test_getProcess() Process { +func test_getProcess() gopsutil.Process { checkPid := os.Getpid() if runtime.GOOS == "windows" { checkPid = 7960 } - ret, _ := NewProcess(int32(checkPid)) + ret, _ := gopsutil.NewProcess(int32(checkPid)) return *ret } func Test_Pids(t *testing.T) { - ret, err := Pids() + ret, err := gopsutil.Pids() if err != nil { t.Errorf("error %v", err) } @@ -31,7 +33,7 @@ func Test_Pid_exists(t *testing.T) { checkPid = 0 } - ret, err := PidExists(int32(checkPid)) + ret, err := gopsutil.PidExists(int32(checkPid)) if err != nil { t.Errorf("error %v", err) } @@ -47,11 +49,11 @@ func Test_NewProcess(t *testing.T) { checkPid = 0 } - ret, err := NewProcess(int32(checkPid)) + ret, err := gopsutil.NewProcess(int32(checkPid)) if err != nil { t.Errorf("error %v", err) } - empty := &Process{} + empty := &gopsutil.Process{} if runtime.GOOS != "windows" { // Windows pid is 0 if empty == ret { t.Errorf("error %v", ret) @@ -65,13 +67,13 @@ func Test_Process_memory_maps(t *testing.T) { if runtime.GOOS == "windows" { checkPid = 0 } - ret, err := NewProcess(int32(checkPid)) + ret, err := gopsutil.NewProcess(int32(checkPid)) mmaps, err := ret.MemoryMaps(false) if err != nil { t.Errorf("memory map get error %v", err) } - empty := MemoryMapsStat{} + empty := gopsutil.MemoryMapsStat{} for _, m := range *mmaps { if m == empty { t.Errorf("memory map get error %v", m) @@ -101,7 +103,7 @@ func Test_Process_IOCounters(t *testing.T) { t.Errorf("geting ppid error %v", err) return } - empty := &IOCountersStat{} + empty := &gopsutil.IOCountersStat{} if v == empty { t.Errorf("error %v", v) }