diff --git a/host/host_linux_ppc64le.go b/host/host_linux_ppc64le.go index 37dbe5c..d081a08 100644 --- a/host/host_linux_ppc64le.go +++ b/host/host_linux_ppc64le.go @@ -1,3 +1,5 @@ +// +build linux +// +build ppc64le // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_linux.go diff --git a/host/host_test.go b/host/host_test.go index 2bf395c..526f0ec 100644 --- a/host/host_test.go +++ b/host/host_test.go @@ -16,6 +16,16 @@ func TestHostInfo(t *testing.T) { } } +func TestUptime(t *testing.T) { + v, err := Uptime() + if err != nil { + t.Errorf("error %v", err) + } + if v == 0 { + t.Errorf("Could not get up time %v", v) + } +} + func TestBoot_time(t *testing.T) { v, err := BootTime() if err != nil { @@ -24,6 +34,9 @@ func TestBoot_time(t *testing.T) { if v == 0 { t.Errorf("Could not get boot time %v", v) } + if v < 946652400 { + t.Errorf("Invalid Boottime, older than 2000-01-01") + } } func TestUsers(t *testing.T) { diff --git a/host/host_windows.go b/host/host_windows.go index 29f900c..18062df 100644 --- a/host/host_windows.go +++ b/host/host_windows.go @@ -50,7 +50,7 @@ func Info() (*InfoStat, error) { boot, err := BootTime() if err == nil { ret.BootTime = boot - ret.Uptime = uptime(boot) + ret.Uptime, _ = Uptime() } procs, err := process.Pids() @@ -76,7 +76,7 @@ func GetOSInfo() (Win32_OperatingSystem, error) { return dst[0], nil } -func BootTime() (uint64, error) { +func Uptime() (uint64, error) { if osInfo == nil { _, err := GetOSInfo() if err != nil { @@ -88,16 +88,16 @@ func BootTime() (uint64, error) { return uint64(now.Sub(t).Seconds()), nil } -func uptime(boot uint64) uint64 { - return uint64(time.Now().Unix()) - boot +func bootTime(up uint64) uint64 { + return uint64(time.Now().Unix()) - up } -func Uptime() (uint64, error) { - boot, err := BootTime() +func BootTime() (uint64, error) { + up, err := Uptime() if err != nil { return 0, err } - return uptime(boot), nil + return bootTime(up), nil } func PlatformInformation() (platform string, family string, version string, err error) {