| OLD | NEW |
| 1 package fuzzcache | 1 package fuzzcache |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "os" | 4 "os" |
| 5 "reflect" | 5 "reflect" |
| 6 "testing" | 6 "testing" |
| 7 | 7 |
| 8 "go.skia.org/infra/fuzzer/go/common" | 8 "go.skia.org/infra/fuzzer/go/common" |
| 9 "go.skia.org/infra/fuzzer/go/frontend/data" | 9 "go.skia.org/infra/fuzzer/go/frontend/data" |
| 10 "go.skia.org/infra/go/testutils" | 10 "go.skia.org/infra/go/testutils" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 t.Errorf("Should have seen error, but did not") | 64 t.Errorf("Should have seen error, but did not") |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 func deleteBeforeTest(t *testing.T) { | 68 func deleteBeforeTest(t *testing.T) { |
| 69 if err := os.Remove(TEST_DB_PATH); err != nil && !os.IsNotExist(err) { | 69 if err := os.Remove(TEST_DB_PATH); err != nil && !os.IsNotExist(err) { |
| 70 t.Fatalf("Could not delete %s: %s", TEST_DB_PATH, err) | 70 t.Fatalf("Could not delete %s: %s", TEST_DB_PATH, err) |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 func makeStacktrace(file, function string, line int) data.StackTrace { | |
| 75 return data.StackTrace{ | |
| 76 Frames: []data.StackTraceFrame{ | |
| 77 { | |
| 78 PackageName: "mock/package/", | |
| 79 FileName: file, | |
| 80 LineNumber: line, | |
| 81 FunctionName: function, | |
| 82 }, | |
| 83 }, | |
| 84 } | |
| 85 } | |
| 86 | |
| 87 var expectedFuzzNames = []string{"aaaa", "bbbb", "cccc", "dddd", "eeee", "ffff",
"gggg"} | 74 var expectedFuzzNames = []string{"aaaa", "bbbb", "cccc", "dddd", "eeee", "ffff",
"gggg"} |
| 88 | 75 |
| 89 var mockFlags = []string{"foo", "bar"} | |
| 90 | |
| 91 var mockPictureDetails = map[string]data.FuzzReport{ | |
| 92 "aaaa": data.FuzzReport{ | |
| 93 DebugStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 94 ReleaseStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 95 DebugFlags: mockFlags, | |
| 96 FuzzName: "aaaa", | |
| 97 FuzzCategory: "skpicture", | |
| 98 }, | |
| 99 "bbbb": data.FuzzReport{ | |
| 100 DebugStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 101 ReleaseStackTrace: data.StackTrace{}, | |
| 102 DebugFlags: mockFlags, | |
| 103 FuzzName: "bbbb", | |
| 104 FuzzCategory: "skpicture", | |
| 105 }, | |
| 106 "cccc": data.FuzzReport{ | |
| 107 DebugStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 108 ReleaseStackTrace: makeStacktrace("alpha", "gamma", 26), | |
| 109 DebugFlags: mockFlags, | |
| 110 FuzzName: "cccc", | |
| 111 FuzzCategory: "skpicture", | |
| 112 }, | |
| 113 "dddd": data.FuzzReport{ | |
| 114 DebugStackTrace: makeStacktrace("alpha", "gamma", 43), | |
| 115 ReleaseStackTrace: makeStacktrace("delta", "epsilon", 125), | |
| 116 DebugFlags: mockFlags, | |
| 117 FuzzName: "dddd", | |
| 118 FuzzCategory: "skpicture", | |
| 119 }, | |
| 120 "eeee": data.FuzzReport{ | |
| 121 DebugStackTrace: data.StackTrace{}, | |
| 122 ReleaseStackTrace: data.StackTrace{}, | |
| 123 DebugFlags: mockFlags, | |
| 124 FuzzName: "eeee", | |
| 125 FuzzCategory: "skpicture", | |
| 126 }, | |
| 127 "ffff": data.FuzzReport{ | |
| 128 DebugStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 129 ReleaseStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 130 DebugFlags: mockFlags, | |
| 131 FuzzName: "ffff", | |
| 132 FuzzCategory: "skpicture", | |
| 133 }, | |
| 134 "gggg": data.FuzzReport{ | |
| 135 DebugStackTrace: makeStacktrace("delta", "epsilon", 122), | |
| 136 ReleaseStackTrace: data.StackTrace{}, | |
| 137 DebugFlags: mockFlags, | |
| 138 FuzzName: "gggg", | |
| 139 FuzzCategory: "skpicture", | |
| 140 }, | |
| 141 } | |
| 142 | |
| 143 var mockAPIDetails = map[string]data.FuzzReport{ | |
| 144 "hhhh": data.FuzzReport{ | |
| 145 DebugStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 146 ReleaseStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 147 DebugFlags: mockFlags, | |
| 148 FuzzName: "hhhh", | |
| 149 FuzzCategory: "api", | |
| 150 }, | |
| 151 "iiii": data.FuzzReport{ | |
| 152 DebugStackTrace: makeStacktrace("alpha", "beta", 16), | |
| 153 ReleaseStackTrace: data.StackTrace{}, | |
| 154 DebugFlags: mockFlags, | |
| 155 FuzzName: "iiii", | |
| 156 FuzzCategory: "api", | |
| 157 }, | |
| 158 } | |
| 159 | |
| 160 var expectedPictureTree = data.FuzzReportTree{ | 76 var expectedPictureTree = data.FuzzReportTree{ |
| 161 data.FileFuzzReport{ | 77 data.FileFuzzReport{ |
| 162 FileName: "mock/package/alpha", Count: 4, Functions: []data.Func
tionFuzzReport{ | 78 FileName: "mock/package/alpha", Count: 4, Functions: []data.Func
tionFuzzReport{ |
| 163 data.FunctionFuzzReport{ | 79 data.FunctionFuzzReport{ |
| 164 FunctionName: "beta", Count: 3, LineNumbers: []d
ata.LineFuzzReport{ | 80 FunctionName: "beta", Count: 3, LineNumbers: []d
ata.LineFuzzReport{ |
| 165 data.LineFuzzReport{ | 81 data.LineFuzzReport{ |
| 166 » » » » » » LineNumber: 16, Count: 3, Detail
s: []data.FuzzReport{mockPictureDetails["aaaa"], mockPictureDetails["bbbb"], moc
kPictureDetails["ffff"]}, | 82 » » » » » » LineNumber: 16, Count: 3, Detail
s: []data.FuzzReport{data.MockReport("skpicture", "aaaa"), data.MockReport("skpi
cture", "bbbb"), data.MockReport("skpicture", "ffff")}, |
| 167 }, | 83 }, |
| 168 }, | 84 }, |
| 169 }, data.FunctionFuzzReport{ | 85 }, data.FunctionFuzzReport{ |
| 170 FunctionName: "gamma", Count: 1, LineNumbers: []
data.LineFuzzReport{ | 86 FunctionName: "gamma", Count: 1, LineNumbers: []
data.LineFuzzReport{ |
| 171 data.LineFuzzReport{ | 87 data.LineFuzzReport{ |
| 172 » » » » » » LineNumber: 26, Count: 1, Detail
s: []data.FuzzReport{mockPictureDetails["cccc"]}, | 88 » » » » » » LineNumber: 26, Count: 1, Detail
s: []data.FuzzReport{data.MockReport("skpicture", "cccc")}, |
| 173 }, | 89 }, |
| 174 }, | 90 }, |
| 175 }, | 91 }, |
| 176 }, | 92 }, |
| 177 }, | 93 }, |
| 178 data.FileFuzzReport{ | 94 data.FileFuzzReport{ |
| 179 FileName: "mock/package/delta", Count: 2, Functions: []data.Func
tionFuzzReport{ | 95 FileName: "mock/package/delta", Count: 2, Functions: []data.Func
tionFuzzReport{ |
| 180 data.FunctionFuzzReport{ | 96 data.FunctionFuzzReport{ |
| 181 FunctionName: "epsilon", Count: 2, LineNumbers:
[]data.LineFuzzReport{ | 97 FunctionName: "epsilon", Count: 2, LineNumbers:
[]data.LineFuzzReport{ |
| 182 data.LineFuzzReport{ | 98 data.LineFuzzReport{ |
| 183 » » » » » » LineNumber: 122, Count: 1, Detai
ls: []data.FuzzReport{mockPictureDetails["gggg"]}, | 99 » » » » » » LineNumber: 122, Count: 1, Detai
ls: []data.FuzzReport{data.MockReport("skpicture", "gggg")}, |
| 184 }, | 100 }, |
| 185 data.LineFuzzReport{ | 101 data.LineFuzzReport{ |
| 186 » » » » » » LineNumber: 125, Count: 1, Detai
ls: []data.FuzzReport{mockPictureDetails["dddd"]}, | 102 » » » » » » LineNumber: 125, Count: 1, Detai
ls: []data.FuzzReport{data.MockReport("skpicture", "dddd")}, |
| 187 }, | 103 }, |
| 188 }, | 104 }, |
| 189 }, | 105 }, |
| 190 }, | 106 }, |
| 191 }, | 107 }, |
| 192 data.FileFuzzReport{ | 108 data.FileFuzzReport{ |
| 193 FileName: common.UNKNOWN_FILE, Count: 1, Functions: []data.Funct
ionFuzzReport{ | 109 FileName: common.UNKNOWN_FILE, Count: 1, Functions: []data.Funct
ionFuzzReport{ |
| 194 data.FunctionFuzzReport{ | 110 data.FunctionFuzzReport{ |
| 195 FunctionName: common.UNKNOWN_FUNCTION, Count: 1,
LineNumbers: []data.LineFuzzReport{ | 111 FunctionName: common.UNKNOWN_FUNCTION, Count: 1,
LineNumbers: []data.LineFuzzReport{ |
| 196 data.LineFuzzReport{ | 112 data.LineFuzzReport{ |
| 197 » » » » » » LineNumber: -1, Count: 1, Detail
s: []data.FuzzReport{mockPictureDetails["eeee"]}, | 113 » » » » » » LineNumber: -1, Count: 1, Detail
s: []data.FuzzReport{data.MockReport("skpicture", "eeee")}, |
| 198 }, | 114 }, |
| 199 }, | 115 }, |
| 200 }, | 116 }, |
| 201 }, | 117 }, |
| 202 }, | 118 }, |
| 203 } | 119 } |
| 204 | 120 |
| 205 var expectedAPITree = data.FuzzReportTree{ | 121 var expectedAPITree = data.FuzzReportTree{ |
| 206 data.FileFuzzReport{ | 122 data.FileFuzzReport{ |
| 207 FileName: "mock/package/alpha", Count: 2, Functions: []data.Func
tionFuzzReport{ | 123 FileName: "mock/package/alpha", Count: 2, Functions: []data.Func
tionFuzzReport{ |
| 208 data.FunctionFuzzReport{ | 124 data.FunctionFuzzReport{ |
| 209 FunctionName: "beta", Count: 2, LineNumbers: []d
ata.LineFuzzReport{ | 125 FunctionName: "beta", Count: 2, LineNumbers: []d
ata.LineFuzzReport{ |
| 210 data.LineFuzzReport{ | 126 data.LineFuzzReport{ |
| 211 » » » » » » LineNumber: 16, Count: 2, Detail
s: []data.FuzzReport{mockAPIDetails["hhhh"], mockAPIDetails["iiii"]}, | 127 » » » » » » LineNumber: 16, Count: 2, Detail
s: []data.FuzzReport{data.MockReport("api", "hhhh"), data.MockReport("api", "iii
i")}, |
| 212 }, | 128 }, |
| 213 }, | 129 }, |
| 214 }, | 130 }, |
| 215 }, | 131 }, |
| 216 }, | 132 }, |
| 217 } | 133 } |
| OLD | NEW |