| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |