Ejemplo n.º 1
0
func TestGetKernelVersion(t *testing.T) {
	have, err := host.GetKernelVersion()
	if err != nil {
		t.Fatal(err)
	}
	if strings.Contains(have, "unknown") {
		t.Fatal(have)
	}
	t.Log(have)
}
Ejemplo n.º 2
0
func TestUname(t *testing.T) {
	oldUname := host.Uname
	defer func() { host.Uname = oldUname }()

	const (
		release = "rls"
		version = "ver"
	)
	host.Uname = func(uts *syscall.Utsname) error {
		uts.Release = string2c(release)
		uts.Version = string2c(version)
		return nil
	}

	have, err := host.GetKernelVersion()
	if err != nil {
		t.Fatal(err)
	}
	if want := fmt.Sprintf("%s %s", release, version); want != have {
		t.Errorf("want %q, have %q", want, have)
	}
}