| 1 | package driverscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/urlscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/" |
| 5 | "osscip-go gomod github.com/golang/go/src go1.24.0 os/" |
| 6 | "path/filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/" |
| 7 | "reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/" |
| 8 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 9 | ) |
| 10 | |
| 11 | // settingsDirAndFile returns a directory in which settings should be stored |
| 12 | // and the name of the settings file. The caller must delete the directory when |
| 13 | // done. |
| 14 | func settingsDirAndFilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settingsDirAndFile().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) (string, string) { |
| 15 | tmpDir, err := osscip-go gomod github.com/golang/go/src go1.24.0 os/.MkdirTempscip-go gomod github.com/golang/go/src go1.24.0 os/MkdirTemp().("", "pprof_settings_test") |
| 16 | if err != nil { |
| 17 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("error creating temporary directory: %v", err) |
| 18 | } |
| 19 | return tmpDir, filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/Join().(tmpDir, "settings.json") |
| 20 | } |
| 21 | |
| 22 | func TestSettingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/TestSettings().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 23 | tmpDir, fname := settingsDirAndFilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settingsDirAndFile().(t) |
| 24 | defer osscip-go gomod github.com/golang/go/src go1.24.0 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.24.0 os/RemoveAll().(tmpDir) |
| 25 | s, err := readSettingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/readSettings().(fname) |
| 26 | if err != nil { |
| 27 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("error reading empty settings: %v", err) |
| 28 | } |
| 29 | if len(s.Configsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settings#Configs.) != 0 { |
| 30 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("expected empty settings; got %v", s) |
| 31 | } |
| 32 | s.Configsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settings#Configs. = append(s.Configsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settings#Configs., namedConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#{ |
| 33 | Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#Name.: "Foo", |
| 34 | configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#config.: configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#{ |
| 35 | Focusscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Focus.: "focus", |
| 36 | // Ensure that transient fields are not saved/restored. |
| 37 | Outputscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Output.: "output", |
| 38 | SourcePathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#SourcePath.: "source", |
| 39 | TrimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#TrimPath.: "trim", |
| 40 | DivideByscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#DivideBy.: -2, |
| 41 | }, |
| 42 | }) |
| 43 | if err := writeSettingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/writeSettings().(fname, s); err != nil { |
| 44 | t.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().(err) |
| 45 | } |
| 46 | s2, err := readSettingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/readSettings().(fname) |
| 47 | if err != nil { |
| 48 | t.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().(err) |
| 49 | } |
| 50 | |
| 51 | // Change the transient fields to their expected values. |
| 52 | s.Configsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settings#Configs.[0].resetTransientscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#resetTransient().() |
| 53 | if !reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.24.0 reflect/DeepEqual().(s, s2) { |
| 54 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("ReadSettings = %v; expected %v", s2, s) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func TestParseConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/TestParseConfig().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 59 | // Use all the fields to check they are saved/restored from URL. |
| 60 | cfg := configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#{ |
| 61 | Outputscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Output.: "", |
| 62 | DropNegativescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#DropNegative.: true, |
| 63 | CallTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#CallTree.: true, |
| 64 | RelativePercentagesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#RelativePercentages.: true, |
| 65 | Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Unit.: "auto", |
| 66 | CompactLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#CompactLabels.: true, |
| 67 | SourcePathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#SourcePath.: "", |
| 68 | TrimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#TrimPath.: "", |
| 69 | NodeCountscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#NodeCount.: 10, |
| 70 | NodeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#NodeFraction.: 0.1, |
| 71 | EdgeFractionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#EdgeFraction.: 0.2, |
| 72 | Trimscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Trim.: true, |
| 73 | Focusscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Focus.: "focus", |
| 74 | Ignorescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Ignore.: "ignore", |
| 75 | PruneFromscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#PruneFrom.: "prune_from", |
| 76 | Hidescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Hide.: "hide", |
| 77 | Showscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Show.: "show", |
| 78 | ShowFromscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#ShowFrom.: "show_from", |
| 79 | TagFocusscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#TagFocus.: "tagfocus", |
| 80 | TagIgnorescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#TagIgnore.: "tagignore", |
| 81 | TagShowscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#TagShow.: "tagshow", |
| 82 | TagHidescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#TagHide.: "taghide", |
| 83 | DivideByscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#DivideBy.: 1, |
| 84 | Meanscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Mean.: true, |
| 85 | Normalizescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Normalize.: true, |
| 86 | Sortscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Sort.: "cum", |
| 87 | Granularityscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Granularity.: "functions", |
| 88 | NoInlinesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#NoInlines.: true, |
| 89 | ShowColumnsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#ShowColumns.: true, |
| 90 | } |
| 91 | url, changed := cfg.makeURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#makeURL().(urlscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/.URLscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#{}) |
| 92 | if !changed { |
| 93 | t.Errorscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Error().("applyConfig returned changed=false after applying non-empty config") |
| 94 | } |
| 95 | cfg2 := defaultConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/defaultConfig().() |
| 96 | if err := cfg2.applyURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#applyURL().(url.Queryscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#Query().()); err != nil { |
| 97 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("fromURL failed: %v", err) |
| 98 | } |
| 99 | if !reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.24.0 reflect/DeepEqual().(cfg, cfg2) { |
| 100 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("parsed config = %+v; expected match with %+v", cfg2, cfg) |
| 101 | } |
| 102 | if url2, changed := cfg.makeURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#makeURL().(url); changed { |
| 103 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("ApplyConfig returned changed=true after applying same config (%q instead of expected %q", url2.Stringscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#String().(), url.Stringscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#String().()) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // TestDefaultConfig verifies that default config values are omitted from URL. |
| 108 | func TestDefaultConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/TestDefaultConfig().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 109 | cfg := defaultConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/defaultConfig().() |
| 110 | url, changed := cfg.makeURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#makeURL().(urlscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/.URLscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#{}) |
| 111 | if changed { |
| 112 | t.Errorscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Error().("applyConfig returned changed=true after applying default config") |
| 113 | } |
| 114 | if url.Stringscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#String().() != "" { |
| 115 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("applyConfig returned %q; expecting %q", url.Stringscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/URL#String().(), "") |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | func TestConfigMenuscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/TestConfigMenu().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 120 | // Save some test settings. |
| 121 | tmpDir, fname := settingsDirAndFilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settingsDirAndFile().(t) |
| 122 | defer osscip-go gomod github.com/golang/go/src go1.24.0 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.24.0 os/RemoveAll().(tmpDir) |
| 123 | a, b := defaultConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/defaultConfig().(), defaultConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/defaultConfig().() |
| 124 | a.Focusscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Focus., b.Focusscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Focus. = "foo", "bar" |
| 125 | s := &settingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settings#{ |
| 126 | Configsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settings#Configs.: []namedConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#{ |
| 127 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#Name.: "A", configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#config.: a}, |
| 128 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#Name.: "B", configscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#config.: b}, |
| 129 | }, |
| 130 | } |
| 131 | if err := writeSettingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/writeSettings().(fname, s); err != nil { |
| 132 | t.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().("error writing settings", err) |
| 133 | } |
| 134 | |
| 135 | pageURL, _ := urlscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.24.0 `net/url`/Parse().("/top?f=foo") |
| 136 | menu := configMenuscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenu().(fname, *pageURL) |
| 137 | want := []configMenuEntryscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#{ |
| 138 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#Name.: "Default", URLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#URL.: "?", Currentscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#Current.: false, UserConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#UserConfig.: false}, |
| 139 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#Name.: "A", URLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#URL.: "?f=foo", Currentscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#Current.: true, UserConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#UserConfig.: true}, |
| 140 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#Name.: "B", URLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#URL.: "?f=bar", Currentscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#Current.: false, UserConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configMenuEntry#UserConfig.: true}, |
| 141 | } |
| 142 | if !reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.24.0 reflect/DeepEqual().(menu, want) { |
| 143 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("ConfigMenu returned %v; want %v", menu, want) |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | func TestEditConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/TestEditConfig().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 148 | tmpDir, fname := settingsDirAndFilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settingsDirAndFile().(t) |
| 149 | defer osscip-go gomod github.com/golang/go/src go1.24.0 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.24.0 os/RemoveAll().(tmpDir) |
| 150 | |
| 151 | type testConfig struct { |
| 152 | name string |
| 153 | focus string |
| 154 | hide string |
| 155 | } |
| 156 | type testCase struct { |
| 157 | remove bool |
| 158 | request string |
| 159 | expect []testConfig |
| 160 | } |
| 161 | for _, c := range []testCase{ |
| 162 | // Create setting c1 |
| 163 | {false, "/?config=c1&f=foo", []testConfig{ |
| 164 | {"c1", "foo", ""}, |
| 165 | }}, |
| 166 | // Create setting c2 |
| 167 | {false, "/?config=c2&h=bar", []testConfig{ |
| 168 | {"c1", "foo", ""}, |
| 169 | {"c2", "", "bar"}, |
| 170 | }}, |
| 171 | // Overwrite c1 |
| 172 | {false, "/?config=c1&f=baz", []testConfig{ |
| 173 | {"c1", "baz", ""}, |
| 174 | {"c2", "", "bar"}, |
| 175 | }}, |
| 176 | // Delete c2 |
| 177 | {true, "c2", []testConfig{ |
| 178 | {"c1", "baz", ""}, |
| 179 | }}, |
| 180 | } { |
| 181 | if c.remove { |
| 182 | if err := removeConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/removeConfig().(fname, c.request); err != nil { |
| 183 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("error removing config %s: %v", c.request, err) |
| 184 | continue |
| 185 | } |
| 186 | } else { |
| 187 | req, err := urlscip-go gomod github.com/golang/go/src go1.24.0 `net/url`/.Parsescip-go gomod github.com/golang/go/src go1.24.0 `net/url`/Parse().(c.request) |
| 188 | if err != nil { |
| 189 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("error parsing request %q: %v", c.request, err) |
| 190 | continue |
| 191 | } |
| 192 | if err := setConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/setConfig().(fname, *req); err != nil { |
| 193 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("error saving request %q: %v", c.request, err) |
| 194 | continue |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | // Check resulting settings. |
| 199 | s, err := readSettingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/readSettings().(fname) |
| 200 | if err != nil { |
| 201 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("error reading settings after applying %q: %v", c.request, err) |
| 202 | continue |
| 203 | } |
| 204 | // Convert to a list that can be compared to c.expect |
| 205 | got := make([]testConfig, len(s.Configsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settings#Configs.)) |
| 206 | for i, c := range s.Configsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/settings#Configs. { |
| 207 | got[i] = testConfig{c.Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/namedConfig#Name., c.Focusscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Focus., c.Hidescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Hide.} |
| 208 | } |
| 209 | if !reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.24.0 reflect/DeepEqual().(got, c.expect) { |
| 210 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("Settings after applying %q = %v; want %v", c.request, got, c.expect) |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | func TestAssignscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/TestAssign().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 216 | baseConfig := currentConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/currentConfig().() |
| 217 | defer setCurrentConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/setCurrentConfig().(baseConfig) |
| 218 | |
| 219 | // Test assigning to a simple field. |
| 220 | if err := configurescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configure().("nodecount", "20"); err != nil { |
| 221 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("error setting nodecount: %v", err) |
| 222 | } |
| 223 | if n := currentConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/currentConfig().().NodeCountscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#NodeCount.; n != 20 { |
| 224 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("incorrect nodecount; expecting 20, got %d", n) |
| 225 | } |
| 226 | |
| 227 | // Test assignment to a group field. |
| 228 | if err := configurescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configure().("granularity", "files"); err != nil { |
| 229 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("error setting granularity: %v", err) |
| 230 | } |
| 231 | if g := currentConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/currentConfig().().Granularityscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Granularity.; g != "files" { |
| 232 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("incorrect granularity; expecting %v, got %v", "files", g) |
| 233 | } |
| 234 | |
| 235 | // Test assignment to one choice of a group field. |
| 236 | if err := configurescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configure().("lines", "t"); err != nil { |
| 237 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("error setting lines: %v", err) |
| 238 | } |
| 239 | if g := currentConfigscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/currentConfig().().Granularityscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/config#Granularity.; g != "lines" { |
| 240 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("incorrect granularity; expecting %v, got %v", "lines", g) |
| 241 | } |
| 242 | |
| 243 | // Test assignment to invalid choice, |
| 244 | if err := configurescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/driver`/configure().("granularity", "cheese"); err == nil { |
| 245 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("allowed assignment of invalid granularity") |
| 246 | } |
| 247 | } |