1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:34:40 -07:00
go/src/net/interface_bsd_test.go
Mikio Hara 041cc148fa net: deflake TestPointToPointInterface and TestInterfaceArrivalAndDeparture
Fixes #6879.

Change-Id: I9ed2460cf14cb9322d9521e7af910efa48abdaf0
Reviewed-on: https://go-review.googlesource.com/23112
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-14 00:53:51 +00:00

56 lines
1.3 KiB
Go

// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin dragonfly freebsd netbsd openbsd
package net
import (
"fmt"
"os/exec"
"runtime"
)
func (ti *testInterface) setBroadcast(vid int) error {
if runtime.GOOS == "openbsd" {
ti.name = fmt.Sprintf("vether%d", vid)
} else {
ti.name = fmt.Sprintf("vlan%d", vid)
}
xname, err := exec.LookPath("ifconfig")
if err != nil {
return err
}
ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
Path: xname,
Args: []string{"ifconfig", ti.name, "create"},
})
ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{
Path: xname,
Args: []string{"ifconfig", ti.name, "destroy"},
})
return nil
}
func (ti *testInterface) setPointToPoint(suffix int) error {
ti.name = fmt.Sprintf("gif%d", suffix)
xname, err := exec.LookPath("ifconfig")
if err != nil {
return err
}
ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
Path: xname,
Args: []string{"ifconfig", ti.name, "create"},
})
ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
Path: xname,
Args: []string{"ifconfig", ti.name, "inet", ti.local, ti.remote},
})
ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{
Path: xname,
Args: []string{"ifconfig", ti.name, "destroy"},
})
return nil
}