MCPcopy Create free account
hub / github.com/google/pprof / makeTestServer

Function makeTestServer

browsertests/testutils.go:17–58  ·  view source on GitHub ↗
(t testing.TB, prof *profile.Profile)

Source from the content-addressed store, hash-verified

15)
16
17func makeTestServer(t testing.TB, prof *profile.Profile) *httptest.Server {
18 if runtime.GOOS == "nacl" || runtime.GOOS == "js" {
19 t.Skip("test assumes tcp available")
20 }
21
22 // Custom http server creator
23 var server *httptest.Server
24 serverCreated := make(chan bool)
25 creator := func(a *driver.HTTPServerArgs) error {
26 server = httptest.NewServer(http.HandlerFunc(
27 func(w http.ResponseWriter, r *http.Request) {
28 if h := a.Handlers[r.URL.Path]; h != nil {
29 h.ServeHTTP(w, r)
30 }
31 }))
32 serverCreated <- true
33 return nil
34 }
35
36 // Start server and wait for it to be initialized
37 go func() {
38 err := driver.PProf(&driver.Options{
39 Obj: fakeObjTool{},
40 UI: testUI{t},
41 Fetch: testFetcher{prof},
42 HTTPServer: creator,
43 Flagset: testFlags{
44 "http": "unused:1234",
45 "no_browser": true,
46 },
47 })
48 if err != nil {
49 panic(err)
50 }
51 }()
52 <-serverCreated
53
54 // Close the server when the test is done.
55 t.Cleanup(server.Close)
56
57 return server
58}
59
60// Fake test implementations of types needed by pprof driver.
61

Callers 3

TestTopTableFunction · 0.70
TestFlameGraphFunction · 0.70
TestSourceFunction · 0.70

Calls 1

PProfFunction · 0.92

Tested by 3

TestTopTableFunction · 0.56
TestFlameGraphFunction · 0.56
TestSourceFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…