]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: relax TestUnshare
authorQuentin Smith <quentin@golang.org>
Wed, 5 Oct 2016 18:37:25 +0000 (14:37 -0400)
committerQuentin Smith <quentin@golang.org>
Wed, 5 Oct 2016 19:30:42 +0000 (19:30 +0000)
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 <bradfitz@golang.org>
Reviewed-by: Jessica Frazelle <me@jessfraz.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/syscall/exec_linux_test.go

index aaffa067bcf656ecf497b90bc37d325771c37168..7a4b5717600325e577981a65710f1f39cd780b3e 100644 (file)
@@ -162,6 +162,12 @@ func TestUnshare(t *testing.T) {
                t.Fatal(err)
        }
 
+       orig, err := ioutil.ReadFile(path)
+       if err != nil {
+               t.Fatal(err)
+       }
+       origLines := strings.Split(strings.TrimSpace(string(orig)), "\n")
+
        cmd := exec.Command("cat", path)
        cmd.SysProcAttr = &syscall.SysProcAttr{
                Unshareflags: syscall.CLONE_NEWNET,
@@ -178,8 +184,8 @@ func TestUnshare(t *testing.T) {
        }
 
        lines := strings.Split(sout, "\n")
-       if len(lines) != 3 {
-               t.Fatalf("Expected 3 lines of output, got %d", len(lines))
+       if len(lines) >= len(origLines) {
+               t.Fatalf("Got %d lines of output, want <%d", len(lines), len(origLines))
        }
 }