MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestIsNetstackRouter

Function TestIsNetstackRouter

wgengine/userspace_ext_test.go:38–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestIsNetstackRouter(t *testing.T) {
39 tests := []struct {
40 name string
41 conf wgengine.Config
42 setNetstackRouter bool
43 want bool
44 }{
45 {
46 name: "no_netstack",
47 conf: wgengine.Config{
48 Tun: newFakeOSTUN(),
49 Router: newFakeOSRouter(),
50 },
51 want: false,
52 },
53 {
54 name: "netstack",
55 conf: wgengine.Config{},
56 want: true,
57 },
58 {
59 name: "hybrid_netstack",
60 conf: wgengine.Config{
61 Tun: newFakeOSTUN(),
62 Router: newFakeOSRouter(),
63 },
64 setNetstackRouter: true,
65 want: true,
66 },
67 }
68 for _, tt := range tests {
69 t.Run(tt.name, func(t *testing.T) {
70 sys := tsd.NewSystem()
71 if tt.setNetstackRouter {
72 sys.NetstackRouter.Set(true)
73 }
74 conf := tt.conf
75 conf.SetSubsystem = sys.Set
76 conf.HealthTracker = sys.HealthTracker.Get()
77 conf.Metrics = sys.UserMetricsRegistry()
78 conf.EventBus = sys.Bus.Get()
79 e, err := wgengine.NewUserspaceEngine(logger.Discard, conf)
80 if err != nil {
81 t.Fatal(err)
82 }
83 defer e.Close()
84 if got := sys.IsNetstackRouter(); got != tt.want {
85 t.Errorf("IsNetstackRouter = %v; want %v", got, tt.want)
86 }
87 })
88 }
89}
90
91func newFakeOSRouter() router.Router {
92 return someRandoOSRouter{router.NewFake(logger.Discard)}

Callers

nothing calls this directly

Calls 12

UserMetricsRegistryMethod · 0.95
IsNetstackRouterMethod · 0.95
NewSystemFunction · 0.92
NewUserspaceEngineFunction · 0.92
newFakeOSTUNFunction · 0.85
newFakeOSRouterFunction · 0.85
RunMethod · 0.65
SetMethod · 0.65
GetMethod · 0.65
FatalMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…