-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add the test for Uname on GOOS=linux
- Loading branch information
1 parent
0e2d558
commit 7d8660a
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package host_test | ||
|
||
import ( | ||
"fmt" | ||
"syscall" | ||
"testing" | ||
|
||
"github.com/weaveworks/scope/probe/host" | ||
) | ||
|
||
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) | ||
} | ||
} | ||
|
||
func string2c(s string) [65]int8 { | ||
var result [65]int8 | ||
for i, c := range s { | ||
result[i] = int8(c) | ||
} | ||
return result | ||
} |