TestDeviceStartStop exercises the startup and shutdown logic of wireguard-go, which is intimately intertwined with magicsock's own lifecycle. We seem to be good at generating deadlocks here, so if this test fails you should suspect a deadlock somewhere in startup or shutdown. It may be an infrequent
(t *testing.T)
| 603 | // or shutdown. It may be an infrequent flake, so run with |
| 604 | // -count=10000 to be sure. |
| 605 | func TestDeviceStartStop(t *testing.T) { |
| 606 | tstest.PanicOnLog() |
| 607 | tstest.ResourceCheck(t) |
| 608 | |
| 609 | bus := eventbus.New() |
| 610 | t.Cleanup(bus.Close) |
| 611 | |
| 612 | netMon, err := netmon.New(bus, logger.WithPrefix(t.Logf, "... netmon: ")) |
| 613 | if err != nil { |
| 614 | t.Fatalf("netmon.New: %v", err) |
| 615 | } |
| 616 | defer netMon.Close() |
| 617 | |
| 618 | conn, err := NewConn(Options{ |
| 619 | EndpointsFunc: func(eps []tailcfg.Endpoint) {}, |
| 620 | Logf: t.Logf, |
| 621 | NetMon: netMon, |
| 622 | EventBus: bus, |
| 623 | Metrics: new(usermetric.Registry), |
| 624 | }) |
| 625 | if err != nil { |
| 626 | t.Fatal(err) |
| 627 | } |
| 628 | defer conn.Close() |
| 629 | |
| 630 | tun := tuntest.NewChannelTUN() |
| 631 | wgLogger := wglog.NewLogger(t.Logf) |
| 632 | dev := wgcfg.NewDevice(tun.TUN(), conn.Bind(), wgLogger.DeviceLogger) |
| 633 | dev.Up() |
| 634 | dev.Close() |
| 635 | } |
| 636 | |
| 637 | // Exercise a code path in sendDiscoMessage if the connection has been closed. |
| 638 | func TestConnClosed(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…