Skip to content

Commit cb986de

Browse files
committed
syscall: relax TestUnshare
Fixes #17224. Some systems have more than just "lo" in a fresh network namespace, due to IPv6. Instead of testing for exactly 3 lines of output (implying 1 interface), just test to make sure that the unshare call resulted in fewer interfaces than before. This should still verify that unshare did something. Change-Id: Iaf84c2b0e673fc207059d62e2f4dd7583a753419 Reviewed-on: https://go-review.googlesource.com/30372 Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Jessica Frazelle <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 92b3e36 commit cb986de

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/syscall/exec_linux_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ func TestUnshare(t *testing.T) {
162162
t.Fatal(err)
163163
}
164164

165+
orig, err := ioutil.ReadFile(path)
166+
if err != nil {
167+
t.Fatal(err)
168+
}
169+
origLines := strings.Split(strings.TrimSpace(string(orig)), "\n")
170+
165171
cmd := exec.Command("cat", path)
166172
cmd.SysProcAttr = &syscall.SysProcAttr{
167173
Unshareflags: syscall.CLONE_NEWNET,
@@ -178,8 +184,8 @@ func TestUnshare(t *testing.T) {
178184
}
179185

180186
lines := strings.Split(sout, "\n")
181-
if len(lines) != 3 {
182-
t.Fatalf("Expected 3 lines of output, got %d", len(lines))
187+
if len(lines) >= len(origLines) {
188+
t.Fatalf("Got %d lines of output, want <%d", len(lines), len(origLines))
183189
}
184190
}
185191

0 commit comments

Comments
 (0)