MCPcopy
hub / github.com/tailscale/tailscale / TestDebugger

Function TestDebugger

tsweb/debug_test.go:18–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestDebugger(t *testing.T) {
19 mux := http.NewServeMux()
20
21 dbg1 := Debugger(mux)
22 if dbg1 == nil {
23 t.Fatal("didn't get a debugger from mux")
24 }
25
26 dbg2 := Debugger(mux)
27 if dbg2 != dbg1 {
28 t.Fatal("Debugger returned different debuggers for the same mux")
29 }
30
31 t.Run("cpu_pprof", func(t *testing.T) {
32 if testing.Short() {
33 t.Skip("skipping second long test")
34 }
35 switch runtime.GOOS {
36 case "linux", "darwin":
37 default:
38 t.Skipf("skipping test on %v", runtime.GOOS)
39 }
40 req := httptest.NewRequest("GET", "/debug/pprof/profile?seconds=1", nil)
41 req.RemoteAddr = "100.101.102.103:1234"
42 rec := httptest.NewRecorder()
43 mux.ServeHTTP(rec, req)
44 res := rec.Result()
45 if res.StatusCode != 200 {
46 t.Errorf("unexpected %v", res.Status)
47 }
48 })
49}
50
51func get(m http.Handler, path, srcIP string) (int, string) {
52 req := httptest.NewRequest("GET", path, nil)

Callers

nothing calls this directly

Calls 9

ShortMethod · 0.80
ResultMethod · 0.80
DebuggerFunction · 0.70
FatalMethod · 0.65
RunMethod · 0.65
SkipMethod · 0.65
SkipfMethod · 0.65
ErrorfMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…