]> Cypherpunks repositories - gostls13.git/commitdiff
net: skip interface tests when required external command not found
authorMikio Hara <mikioh.mikioh@gmail.com>
Sat, 2 Mar 2013 01:56:51 +0000 (10:56 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Sat, 2 Mar 2013 01:56:51 +0000 (10:56 +0900)
Fixes #4952.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/7445046

src/pkg/net/interface_bsd_test.go
src/pkg/net/interface_linux_test.go
src/pkg/net/interface_unix_test.go

index c6e1bf731a8e3e8040a97a9d408141d620695ea8..aa1141903b240bfffc42266ed2bcf1a714130eff 100644 (file)
@@ -11,11 +11,11 @@ import (
        "os/exec"
 )
 
-func (ti *testInterface) setBroadcast(suffix int) {
+func (ti *testInterface) setBroadcast(suffix int) error {
        ti.name = fmt.Sprintf("vlan%d", suffix)
        xname, err := exec.LookPath("ifconfig")
        if err != nil {
-               xname = "ifconfig"
+               return err
        }
        ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
                Path: xname,
@@ -25,15 +25,16 @@ func (ti *testInterface) setBroadcast(suffix int) {
                Path: xname,
                Args: []string{"ifconfig", ti.name, "destroy"},
        })
+       return nil
 }
 
-func (ti *testInterface) setPointToPoint(suffix int, local, remote string) {
+func (ti *testInterface) setPointToPoint(suffix int, local, remote string) error {
        ti.name = fmt.Sprintf("gif%d", suffix)
        ti.local = local
        ti.remote = remote
        xname, err := exec.LookPath("ifconfig")
        if err != nil {
-               xname = "ifconfig"
+               return err
        }
        ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
                Path: xname,
@@ -47,4 +48,5 @@ func (ti *testInterface) setPointToPoint(suffix int, local, remote string) {
                Path: xname,
                Args: []string{"ifconfig", ti.name, "destroy"},
        })
+       return nil
 }
index 50d3dc6240673befa59cef07f055a14c6bbd7d40..085d3de9d23365885b194b881bba141c2d4a35c1 100644 (file)
@@ -10,11 +10,11 @@ import (
        "testing"
 )
 
-func (ti *testInterface) setBroadcast(suffix int) {
+func (ti *testInterface) setBroadcast(suffix int) error {
        ti.name = fmt.Sprintf("gotest%d", suffix)
        xname, err := exec.LookPath("ip")
        if err != nil {
-               xname = "ip"
+               return err
        }
        ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
                Path: xname,
@@ -24,15 +24,16 @@ func (ti *testInterface) setBroadcast(suffix int) {
                Path: xname,
                Args: []string{"ip", "link", "delete", ti.name, "type", "dummy"},
        })
+       return nil
 }
 
-func (ti *testInterface) setPointToPoint(suffix int, local, remote string) {
+func (ti *testInterface) setPointToPoint(suffix int, local, remote string) error {
        ti.name = fmt.Sprintf("gotest%d", suffix)
        ti.local = local
        ti.remote = remote
        xname, err := exec.LookPath("ip")
        if err != nil {
-               xname = "ip"
+               return err
        }
        ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
                Path: xname,
@@ -44,12 +45,13 @@ func (ti *testInterface) setPointToPoint(suffix int, local, remote string) {
        })
        xname, err = exec.LookPath("ifconfig")
        if err != nil {
-               xname = "ifconfig"
+               return err
        }
        ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
                Path: xname,
                Args: []string{"ifconfig", ti.name, "inet", local, "dstaddr", remote},
        })
+       return nil
 }
 
 const (
index 2040d163e4742d70f07507fea3b8e1b66c4ea8a2..6dbd6e6e7beef3ec83605d158b4ccc1d55d870e3 100644 (file)
@@ -53,7 +53,9 @@ func TestPointToPointInterface(t *testing.T) {
        ip := ParseIP(remote)
        for i := 0; i < 3; i++ {
                ti := &testInterface{}
-               ti.setPointToPoint(5963+i, local, remote)
+               if err := ti.setPointToPoint(5963+i, local, remote); err != nil {
+                       t.Skipf("test requries external command: %v", err)
+               }
                if err := ti.setup(); err != nil {
                        t.Fatalf("testInterface.setup failed: %v", err)
                } else {
@@ -98,7 +100,9 @@ func TestInterfaceArrivalAndDeparture(t *testing.T) {
                        t.Fatalf("Interfaces failed: %v", err)
                }
                ti := &testInterface{}
-               ti.setBroadcast(5682 + i)
+               if err := ti.setBroadcast(5682 + i); err != nil {
+                       t.Skipf("test requires external command: %v", err)
+               }
                if err := ti.setup(); err != nil {
                        t.Fatalf("testInterface.setup failed: %v", err)
                } else {