Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: fuzzer/go/data/report.go

Issue 1695803002: Improve fuzz counts (Closed) Base URL: https://skia.googlesource.com/buildbot@dedup-first
Patch Set: Add docs Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | fuzzer/go/frontend/syncer/fuzz_syncer.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package data 1 package data
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "encoding/gob" 5 "encoding/gob"
6 "fmt" 6 "fmt"
7 "sort" 7 "sort"
8 "sync" 8 "sync"
9 9
10 "github.com/skia-dev/glog" 10 "github.com/skia-dev/glog"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 return nil, fmt.Errorf("Fuzz with name %q not found", name) 149 return nil, fmt.Errorf("Fuzz with name %q not found", name)
150 } 150 }
151 151
152 // filterByFuzzName filters out all functions that do not contain a fuzz with th e given 152 // filterByFuzzName filters out all functions that do not contain a fuzz with th e given
153 // name and returns true. If such a fuzz does not exist, it returns false. 153 // name and returns true. If such a fuzz does not exist, it returns false.
154 func (file *FileFuzzReport) filterByFuzzName(name string) bool { 154 func (file *FileFuzzReport) filterByFuzzName(name string) bool {
155 for _, function := range file.Functions { 155 for _, function := range file.Functions {
156 if function.filterByFuzzName(name) { 156 if function.filterByFuzzName(name) {
157 file.Functions = []FunctionFuzzReport{function} 157 file.Functions = []FunctionFuzzReport{function}
158 file.Count = 1
158 return true 159 return true
159 } 160 }
160 } 161 }
161 return false 162 return false
162 } 163 }
163 164
164 // filterByFuzzName filters out all lines that do not contain a fuzz with the gi ven 165 // filterByFuzzName filters out all lines that do not contain a fuzz with the gi ven
165 // name and returns true. If such a fuzz does not exist, it returns false. 166 // name and returns true. If such a fuzz does not exist, it returns false.
166 func (function *FunctionFuzzReport) filterByFuzzName(name string) bool { 167 func (function *FunctionFuzzReport) filterByFuzzName(name string) bool {
167 for _, line := range function.LineNumbers { 168 for _, line := range function.LineNumbers {
168 if line.filterByFuzzName(name) { 169 if line.filterByFuzzName(name) {
169 function.LineNumbers = []LineFuzzReport{line} 170 function.LineNumbers = []LineFuzzReport{line}
171 function.Count = 1
170 return true 172 return true
171 } 173 }
172 } 174 }
173 return false 175 return false
174 } 176 }
175 177
176 // filterByFuzzName filters out all fuzzes that do not have the given 178 // filterByFuzzName filters out all fuzzes that do not have the given
177 // name and returns true. If such a fuzz does not exist, it returns false. 179 // name and returns true. If such a fuzz does not exist, it returns false.
178 func (line *LineFuzzReport) filterByFuzzName(name string) bool { 180 func (line *LineFuzzReport) filterByFuzzName(name string) bool {
179 if b, hasIt := line.Details.containsName(name); hasIt { 181 if b, hasIt := line.Details.containsName(name); hasIt {
180 line.Details = SortedFuzzReports{b} 182 line.Details = SortedFuzzReports{b}
183 line.Count = 1
181 return true 184 return true
182 } 185 }
183 return false 186 return false
184 } 187 }
185 188
186 func NewFuzzFound(category string, b FuzzReport) { 189 func NewFuzzFound(category string, b FuzzReport) {
187 // set the category if it has not already been set 190 // set the category if it has not already been set
188 b.FuzzCategory = category 191 b.FuzzCategory = category
189 stagingData.addFuzzReport(category, b) 192 stagingData.addFuzzReport(category, b)
190 } 193 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 459 }
457 460
458 // containsName returns the FuzzReport and true if a fuzz with the given name is in the list. 461 // containsName returns the FuzzReport and true if a fuzz with the given name is in the list.
459 func (p SortedFuzzReports) containsName(fuzzName string) (FuzzReport, bool) { 462 func (p SortedFuzzReports) containsName(fuzzName string) (FuzzReport, bool) {
460 i := sort.Search(len(p), func(i int) bool { return p[i].FuzzName >= fuzz Name }) 463 i := sort.Search(len(p), func(i int) bool { return p[i].FuzzName >= fuzz Name })
461 if i < len(p) && p[i].FuzzName == fuzzName { 464 if i < len(p) && p[i].FuzzName == fuzzName {
462 return p[i], true 465 return p[i], true
463 } 466 }
464 return FuzzReport{}, false 467 return FuzzReport{}, false
465 } 468 }
OLDNEW
« no previous file with comments | « no previous file | fuzzer/go/frontend/syncer/fuzz_syncer.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698