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