2014-07-24 01:41:10 +08:00
|
|
|
package netlink
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCreateBridgeWithMac(t *testing.T) {
|
|
|
|
name := "testbridge"
|
|
|
|
|
|
|
|
if err := CreateBridge(name, true); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := net.InterfaceByName(name); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// cleanup and tests
|
|
|
|
|
|
|
|
if err := DeleteBridge(name); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := net.InterfaceByName(name); err == nil {
|
|
|
|
t.Fatal("expected error getting interface because bridge was deleted")
|
|
|
|
}
|
|
|
|
}
|
2014-07-24 02:34:07 +08:00
|
|
|
|
|
|
|
func TestCreateVethPair(t *testing.T) {
|
|
|
|
var (
|
|
|
|
name1 = "veth1"
|
|
|
|
name2 = "veth2"
|
|
|
|
)
|
|
|
|
|
|
|
|
if err := NetworkCreateVethPair(name1, name2); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := net.InterfaceByName(name1); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := net.InterfaceByName(name2); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|