[host]Windows: BootTime and Uptime are reversed on Windows.
This commit is contained in:
parent
e9afb36ccf
commit
53406b2832
|
@ -1,3 +1,5 @@
|
|||
// +build linux
|
||||
// +build ppc64le
|
||||
// Created by cgo -godefs - DO NOT EDIT
|
||||
// cgo -godefs types_linux.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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue