mirror of
https://github.com/yggdrasil-network/water.git
synced 2025-05-19 16:35:10 +03:00
tear down device at end of test
This commit is contained in:
parent
af2921498b
commit
240a3d7b51
2 changed files with 20 additions and 0 deletions
|
@ -21,6 +21,15 @@ func setupIfce(t *testing.T, self net.IP, remote net.IP, dev string) {
|
|||
}
|
||||
}
|
||||
|
||||
func teardownIfce(t *testing.T, ifce *Interface) {
|
||||
if err := ifce.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := exec.Command("ifconfig", ifce.Name(), "down").Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestP2PTUN(t *testing.T) {
|
||||
var (
|
||||
self = net.IPv4(10, 0, 42, 1)
|
||||
|
@ -31,6 +40,7 @@ func TestP2PTUN(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("creating TUN error: %v\n", err)
|
||||
}
|
||||
defer teardownIfce(t, ifce)
|
||||
|
||||
dataCh := make(chan []byte)
|
||||
errCh := make(chan error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue