"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,
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,
Path: xname,
Args: []string{"ifconfig", ti.name, "destroy"},
})
+ return nil
}
"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,
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,
})
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 (
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 {
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 {