MCPcopy
hub / github.com/tailscale/tailscale / TestDeviceStartStop

Function TestDeviceStartStop

wgengine/magicsock/magicsock_test.go:605–635  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

603// or shutdown. It may be an infrequent flake, so run with
604// -count=10000 to be sure.
605func 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.
638func TestConnClosed(t *testing.T) {

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
BindMethod · 0.95
PanicOnLogFunction · 0.92
ResourceCheckFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
WithPrefixFunction · 0.92
NewLoggerFunction · 0.92
NewDeviceFunction · 0.92
NewConnFunction · 0.70
CleanupMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…