OLD | NEW |
1 package data | 1 package data |
2 | 2 |
3 import ( | 3 import ( |
4 "path/filepath" | 4 "path/filepath" |
5 "reflect" | 5 "reflect" |
| 6 "strings" |
6 "testing" | 7 "testing" |
7 | 8 |
| 9 "go.skia.org/infra/fuzzer/go/common" |
8 "go.skia.org/infra/go/testutils" | 10 "go.skia.org/infra/go/testutils" |
9 ) | 11 ) |
10 | 12 |
11 func TestParseReleaseDump(t *testing.T) { | 13 func TestParseReleaseDump(t *testing.T) { |
12 testInput := testutils.MustReadFile("parse-catchsegv-release.dump") | 14 testInput := testutils.MustReadFile("parse-catchsegv-release.dump") |
13 » trace := ParseStackTrace(testInput) | 15 » trace := parseCatchsegvStackTrace(testInput) |
14 expected := StackTrace{ | 16 expected := StackTrace{ |
15 Frames: []StackTraceFrame{ | 17 Frames: []StackTraceFrame{ |
16 FullStackFrame("src/core/", "SkReadBuffer.cpp", "readFla
ttenable", 344), | 18 FullStackFrame("src/core/", "SkReadBuffer.cpp", "readFla
ttenable", 344), |
17 FullStackFrame("src/core/", "SkReadBuffer.h", "readFlatt
enable", 130), | 19 FullStackFrame("src/core/", "SkReadBuffer.h", "readFlatt
enable", 130), |
18 FullStackFrame("src/core/", "SkPictureData.cpp", "parseB
ufferTag", 498), | 20 FullStackFrame("src/core/", "SkPictureData.cpp", "parseB
ufferTag", 498), |
19 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
treamTag", 424), | 21 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
treamTag", 424), |
20 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
tream", 580), | 22 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
tream", 580), |
21 FullStackFrame("src/core/", "SkPicture.cpp", "CreateFrom
Stream", 153), | 23 FullStackFrame("src/core/", "SkPicture.cpp", "CreateFrom
Stream", 153), |
22 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
treamTag", 392), | 24 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
treamTag", 392), |
23 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
tream", 580), | 25 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
tream", 580), |
24 FullStackFrame("src/core/", "SkPicture.cpp", "CreateFrom
Stream", 153), | 26 FullStackFrame("src/core/", "SkPicture.cpp", "CreateFrom
Stream", 153), |
25 FullStackFrame("fuzzer_cache/src/", "parseskp.cpp", "too
l_main", 41), | 27 FullStackFrame("fuzzer_cache/src/", "parseskp.cpp", "too
l_main", 41), |
26 }, | 28 }, |
27 } | 29 } |
28 if !reflect.DeepEqual(expected, trace) { | 30 if !reflect.DeepEqual(expected, trace) { |
29 t.Errorf("Expected %#v\nbut was %#v", expected, trace) | 31 t.Errorf("Expected %#v\nbut was %#v", expected, trace) |
30 } | 32 } |
31 } | 33 } |
32 | 34 |
33 func TestParseDebugDump(t *testing.T) { | 35 func TestParseDebugDump(t *testing.T) { |
34 testInput := testutils.MustReadFile("parse-catchsegv-debug.dump") | 36 testInput := testutils.MustReadFile("parse-catchsegv-debug.dump") |
35 | 37 |
36 » trace := ParseStackTrace(testInput) | 38 » trace := parseCatchsegvStackTrace(testInput) |
37 | 39 |
38 expected := StackTrace{ | 40 expected := StackTrace{ |
39 Frames: []StackTraceFrame{ | 41 Frames: []StackTraceFrame{ |
40 FullStackFrame("src/core/", "SkReadBuffer.cpp", "readFla
ttenable", 343), | 42 FullStackFrame("src/core/", "SkReadBuffer.cpp", "readFla
ttenable", 343), |
41 FullStackFrame("src/core/", "SkReadBuffer.h", "readFlatt
enable", 130), | 43 FullStackFrame("src/core/", "SkReadBuffer.h", "readFlatt
enable", 130), |
42 FullStackFrame("src/core/", "SkReadBuffer.h", "readPathE
ffect", 136), | 44 FullStackFrame("src/core/", "SkReadBuffer.h", "readPathE
ffect", 136), |
43 FullStackFrame("src/core/", "SkPaint.cpp", "unflatten",
1971), | 45 FullStackFrame("src/core/", "SkPaint.cpp", "unflatten",
1971), |
44 FullStackFrame("src/core/", "SkReadBuffer.h", "readPaint
", 126), | 46 FullStackFrame("src/core/", "SkReadBuffer.h", "readPaint
", 126), |
45 FullStackFrame("src/core/", "SkPictureData.cpp", "parseB
ufferTag", 498), | 47 FullStackFrame("src/core/", "SkPictureData.cpp", "parseB
ufferTag", 498), |
46 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
treamTag", 424), | 48 FullStackFrame("src/core/", "SkPictureData.cpp", "parseS
treamTag", 424), |
(...skipping 10 matching lines...) Loading... |
57 } | 59 } |
58 | 60 |
59 if !reflect.DeepEqual(expected, trace) { | 61 if !reflect.DeepEqual(expected, trace) { |
60 t.Errorf("Expected %#v\nbut was %#v", expected, trace) | 62 t.Errorf("Expected %#v\nbut was %#v", expected, trace) |
61 } | 63 } |
62 } | 64 } |
63 | 65 |
64 func TestParsingEdgeCases(t *testing.T) { | 66 func TestParsingEdgeCases(t *testing.T) { |
65 // This is a made up dump that has the edge cases for parsing function n
ames. | 67 // This is a made up dump that has the edge cases for parsing function n
ames. |
66 testInput := testutils.MustReadFile("parse-catchsegv-edge.dump") | 68 testInput := testutils.MustReadFile("parse-catchsegv-edge.dump") |
67 » trace := ParseStackTrace(testInput) | 69 » trace := parseCatchsegvStackTrace(testInput) |
68 expected := StackTrace{ | 70 expected := StackTrace{ |
69 Frames: []StackTraceFrame{ | 71 Frames: []StackTraceFrame{ |
70 FullStackFrame("src/codec/", "SkMasks.cpp", "convert_to_
8", 54), | 72 FullStackFrame("src/codec/", "SkMasks.cpp", "convert_to_
8", 54), |
71 FullStackFrame("src/codec/", "SkBmpMaskCodec.cpp", "deco
deRows", 93), | 73 FullStackFrame("src/codec/", "SkBmpMaskCodec.cpp", "deco
deRows", 93), |
72 FullStackFrame("src/core/", "SkClipStack.cpp", "Element:
:updateBoundAndGenID", 483), | 74 FullStackFrame("src/core/", "SkClipStack.cpp", "Element:
:updateBoundAndGenID", 483), |
73 FullStackFrame("src/core/", "SkClipStack.cpp", "pushElem
ent", 719), | 75 FullStackFrame("src/core/", "SkClipStack.cpp", "pushElem
ent", 719), |
74 FullStackFrame("dm/", "DMSrcSink.cpp", "SKPSrc::draw", 7
51), | 76 FullStackFrame("dm/", "DMSrcSink.cpp", "SKPSrc::draw", 7
51), |
75 FullStackFrame("src/core/", "SkReader32.h", "eof", 38), | 77 FullStackFrame("src/core/", "SkReader32.h", "eof", 38), |
76 FullStackFrame("src/core/", "SkTaskGroup.cpp", "ThreadPo
ol::Wait", 88), | 78 FullStackFrame("src/core/", "SkTaskGroup.cpp", "ThreadPo
ol::Wait", 88), |
77 FullStackFrame("fuzz/", "fuzz.cpp", "fuzz_img", 110), | 79 FullStackFrame("fuzz/", "fuzz.cpp", "fuzz_img", 110), |
78 }, | 80 }, |
79 } | 81 } |
80 | 82 |
81 if !reflect.DeepEqual(expected, trace) { | 83 if !reflect.DeepEqual(expected, trace) { |
82 t.Errorf("Expected %#v\nbut was %#v", expected, trace) | 84 t.Errorf("Expected %#v\nbut was %#v", expected, trace) |
83 t.Errorf("Expected \n%s\nbut was \n%s", expected.String(), trace
.String()) | 85 t.Errorf("Expected \n%s\nbut was \n%s", expected.String(), trace
.String()) |
84 } | 86 } |
85 } | 87 } |
86 | 88 |
| 89 func TestParseASANSingle(t *testing.T) { |
| 90 testInput := testutils.MustReadFile("parse-asan-single.asan") |
| 91 |
| 92 trace := parseASANStackTrace(testInput) |
| 93 |
| 94 expected := StackTrace{ |
| 95 Frames: []StackTraceFrame{ |
| 96 FullStackFrame("src/codec/", "SkMasks.cpp", "convert_to_
8", 54), |
| 97 FullStackFrame("src/codec/", "SkMaskSwizzler.cpp", "swiz
zle_mask24_to_n32_opaque", 93), |
| 98 FullStackFrame("src/codec/", "SkBmpMaskCodec.cpp", "SkBm
pMaskCodec::decodeRows", 103), |
| 99 FullStackFrame("src/codec/", "SkBmpMaskCodec.cpp", "SkBm
pMaskCodec::onGetPixels", 53), |
| 100 FullStackFrame("src/codec/", "SkCodec.cpp", "SkCodec::ge
tPixels", 204), |
| 101 FullStackFrame("fuzz/", "fuzz.cpp", "fuzz_img", 119), |
| 102 FullStackFrame("fuzz/", "fuzz.cpp", "main", 53), |
| 103 }, |
| 104 } |
| 105 |
| 106 if !reflect.DeepEqual(expected, trace) { |
| 107 t.Errorf("Expected %#v\nbut was %#v", expected, trace) |
| 108 t.Errorf("Expected %s \n but was %s", expected.String(), trace.S
tring()) |
| 109 } |
| 110 } |
| 111 |
| 112 func TestParseASANDouble(t *testing.T) { |
| 113 testInput := testutils.MustReadFile("parse-asan-double.asan") |
| 114 |
| 115 trace := parseASANStackTrace(testInput) |
| 116 |
| 117 expected := StackTrace{ |
| 118 Frames: []StackTraceFrame{ |
| 119 FullStackFrame("src/core/", "SkReader32.h", "SkReader32:
:readInt_asan", 57), |
| 120 FullStackFrame("src/core/", "SkPicturePlayback.cpp", "Sk
PicturePlayback::handleOp", 151), |
| 121 FullStackFrame("src/core/", "SkPicturePlayback.cpp", "Sk
PicturePlayback::draw", 111), |
| 122 FullStackFrame("src/core/", "SkPicture.cpp", "SkPicture:
:Forwardport", 137), |
| 123 FullStackFrame("src/core/", "SkPicture.cpp", "SkPicture:
:CreateFromStream", 154), |
| 124 FullStackFrame("fuzz/", "fuzz.cpp", "fuzz_skp", 143), |
| 125 FullStackFrame("fuzz/", "fuzz.cpp", "main", 54), |
| 126 }, |
| 127 } |
| 128 |
| 129 if !reflect.DeepEqual(expected, trace) { |
| 130 t.Errorf("Expected %#v\nbut was %#v", expected, trace) |
| 131 t.Errorf("Expected %s \n but was %s", expected.String(), trace.S
tring()) |
| 132 } |
| 133 } |
| 134 |
87 func TestParseEmptyStackTrace(t *testing.T) { | 135 func TestParseEmptyStackTrace(t *testing.T) { |
88 » trace := ParseStackTrace("") | 136 » trace := parseCatchsegvStackTrace("") |
89 | 137 |
90 if !trace.IsEmpty() { | 138 if !trace.IsEmpty() { |
91 t.Errorf("Expected stacktrace to be empty but was %#v", trace) | 139 t.Errorf("Expected stacktrace to be empty but was %#v", trace) |
92 } | 140 } |
93 } | 141 } |
94 | 142 |
95 func stacktrace(file string) string { | 143 func stacktrace(file string) string { |
96 return filepath.Join("stacktrace", file) | 144 return filepath.Join("stacktrace", file) |
97 } | 145 } |
| 146 |
| 147 func TestParseGCSPackage_Grey(t *testing.T) { |
| 148 // Everything was successful or partially successful |
| 149 g := GCSPackage{ |
| 150 Debug: OutputFiles{ |
| 151 Asan: testutils.MustReadFile(stacktrace("0grey_debug.a
san")), |
| 152 Dump: "", |
| 153 StdErr: testutils.MustReadFile(stacktrace("0grey_debug.e
rr")), |
| 154 }, |
| 155 Release: OutputFiles{ |
| 156 Asan: testutils.MustReadFile(stacktrace("0grey_release
.asan")), |
| 157 Dump: "", |
| 158 StdErr: testutils.MustReadFile(stacktrace("0grey_release
.err")), |
| 159 }, |
| 160 FuzzCategory: "skcodec", |
| 161 } |
| 162 |
| 163 result := ParseGCSPackage(g) |
| 164 expectedDebugFlags := TerminatedGracefully |
| 165 expectedReleaseFlags := TerminatedGracefully |
| 166 if result.Debug.Flags != expectedDebugFlags { |
| 167 t.Errorf("Parsed Debug flags were wrong. Expected %s, but was %
s", expectedDebugFlags.String(), result.Debug.Flags.String()) |
| 168 } |
| 169 if result.Release.Flags != expectedReleaseFlags { |
| 170 t.Errorf("Parsed Release flags were wrong. Expected %s, but was
%s", expectedReleaseFlags.String(), result.Release.Flags.String()) |
| 171 } |
| 172 if !result.Debug.StackTrace.IsEmpty() { |
| 173 t.Errorf("Should have had empty debug stacktrace, but was %s", r
esult.Debug.StackTrace.String()) |
| 174 } |
| 175 if !result.Release.StackTrace.IsEmpty() { |
| 176 t.Errorf("Should have had empty release stacktrace, but was %s",
result.Release.StackTrace.String()) |
| 177 } |
| 178 } |
| 179 |
| 180 // For the following tests, I added the suffix _asan and _dump to the top stackt
race line in the |
| 181 // raw files, so we can tell where the stacktrace is being parsed from easily, i
f there are two |
| 182 // possibilities. The analysis should try to reason about the AddressSanitizer o
utput, with a |
| 183 // fallback to the catchsegv debug/err output. |
| 184 |
| 185 func TestParseGCSPackage_GlobalStackOverflow(t *testing.T) { |
| 186 // Both debug/release crashed with a stackoverflow. |
| 187 g := GCSPackage{ |
| 188 Debug: OutputFiles{ |
| 189 Asan: testutils.MustReadFile(stacktrace("1bad_debug.as
an")), |
| 190 Dump: "", |
| 191 StdErr: testutils.MustReadFile(stacktrace("1grey_debug.e
rr")), |
| 192 }, |
| 193 Release: OutputFiles{ |
| 194 Asan: testutils.MustReadFile(stacktrace("1bad_release.
asan")), |
| 195 Dump: "", |
| 196 StdErr: testutils.MustReadFile(stacktrace("1grey_release
.err")), |
| 197 }, |
| 198 FuzzCategory: "skcodec", |
| 199 } |
| 200 |
| 201 result := ParseGCSPackage(g) |
| 202 expectedDebugFlags := ASANCrashed | ASAN_GlobalBufferOverflow |
| 203 expectedReleaseFlags := ASANCrashed | ASAN_GlobalBufferOverflow |
| 204 if result.Debug.Flags != expectedDebugFlags { |
| 205 t.Errorf("Parsed Debug flags were wrong. Expected %s, but was %
s", expectedDebugFlags.String(), result.Debug.Flags.String()) |
| 206 } |
| 207 if result.Release.Flags != expectedReleaseFlags { |
| 208 t.Errorf("Parsed Release flags were wrong. Expected %s, but was
%s", expectedReleaseFlags.String(), result.Release.Flags.String()) |
| 209 } |
| 210 // There was no catchsegv dump, so only one possibility for stacktrace f
or both of these. |
| 211 if result.Debug.StackTrace.IsEmpty() { |
| 212 t.Errorf("Should not have had empty debug stacktrace") |
| 213 } |
| 214 if result.Release.StackTrace.IsEmpty() { |
| 215 t.Errorf("Should not have had empty release stacktrace") |
| 216 } |
| 217 } |
| 218 |
| 219 func TestParseGCSPackage_AssertDuringRendering(t *testing.T) { |
| 220 // Debug assert hit. Release heap buffer overflow |
| 221 g := GCSPackage{ |
| 222 Debug: OutputFiles{ |
| 223 Asan: testutils.MustReadFile(stacktrace("2bad_debug.as
an")), |
| 224 Dump: testutils.MustReadFile(stacktrace("2bad_debug.du
mp")), |
| 225 StdErr: testutils.MustReadFile(stacktrace("2bad_debug.er
r")), |
| 226 }, |
| 227 Release: OutputFiles{ |
| 228 Asan: testutils.MustReadFile(stacktrace("2bad_release.
asan")), |
| 229 Dump: "", |
| 230 StdErr: testutils.MustReadFile(stacktrace("2grey_release
.err")), |
| 231 }, |
| 232 FuzzCategory: "skpicture", |
| 233 } |
| 234 |
| 235 result := ParseGCSPackage(g) |
| 236 expectedDebugFlags := ASANCrashed | ClangCrashed | AssertionViolated |
| 237 expectedReleaseFlags := ASANCrashed | ASAN_HeapBufferOverflow | SKPICTUR
E_DuringRendering |
| 238 if result.Debug.Flags != expectedDebugFlags { |
| 239 t.Errorf("Parsed Debug flags were wrong. Expected %s, but was %
s", expectedDebugFlags.String(), result.Debug.Flags.String()) |
| 240 } |
| 241 if result.Release.Flags != expectedReleaseFlags { |
| 242 t.Errorf("Parsed Release flags were wrong. Expected %s, but was
%s", expectedReleaseFlags.String(), result.Release.Flags.String()) |
| 243 } |
| 244 stack := result.Debug.StackTrace |
| 245 if stack.IsEmpty() { |
| 246 t.Errorf("Should not have had empty debug stacktrace") |
| 247 } else { |
| 248 if !strings.HasSuffix(stack.Frames[0].FunctionName, "_asan") { |
| 249 t.Errorf("Should have parsed stacktrace from asan: \n%s"
, stack.String()) |
| 250 } |
| 251 } |
| 252 // There was no catchsegv dump, so only one possibility for stacktrace. |
| 253 if result.Release.StackTrace.IsEmpty() { |
| 254 t.Errorf("Should not have had empty release stacktrace") |
| 255 } |
| 256 } |
| 257 |
| 258 func TestParseGCSPackage_UseAfterFree(t *testing.T) { |
| 259 // Debug ClangCrashed. Release heap use after free. |
| 260 g := GCSPackage{ |
| 261 Debug: OutputFiles{ |
| 262 Asan: testutils.MustReadFile(stacktrace("3grey_debug.a
san")), |
| 263 Dump: testutils.MustReadFile(stacktrace("3bad_debug.du
mp")), |
| 264 StdErr: "", |
| 265 }, |
| 266 Release: OutputFiles{ |
| 267 Asan: testutils.MustReadFile(stacktrace("3bad_release.
asan")), |
| 268 Dump: testutils.MustReadFile(stacktrace("3bad_release.
dump")), |
| 269 StdErr: "", |
| 270 }, |
| 271 FuzzCategory: "skpicture", |
| 272 } |
| 273 |
| 274 result := ParseGCSPackage(g) |
| 275 expectedDebugFlags := ClangCrashed |
| 276 expectedReleaseFlags := ASANCrashed | ClangCrashed | ASAN_HeapUseAfterFr
ee |
| 277 if result.Debug.Flags != expectedDebugFlags { |
| 278 t.Errorf("Parsed Debug flags were wrong. Expected %s, but was %
s", expectedDebugFlags.String(), result.Debug.Flags.String()) |
| 279 } |
| 280 if result.Release.Flags != expectedReleaseFlags { |
| 281 t.Errorf("Parsed Release flags were wrong. Expected %s, but was
%s", expectedReleaseFlags.String(), result.Release.Flags.String()) |
| 282 } |
| 283 stack := result.Debug.StackTrace |
| 284 // There was no asan dump, so only one possibility for stacktrace. |
| 285 if stack.IsEmpty() { |
| 286 t.Errorf("Should not have had empty debug stacktrace") |
| 287 } |
| 288 stack = result.Release.StackTrace |
| 289 if stack.IsEmpty() { |
| 290 t.Errorf("Should not have had empty release stacktrace") |
| 291 } else { |
| 292 if !strings.HasSuffix(stack.Frames[0].FunctionName, "_asan") { |
| 293 t.Errorf("Should have parsed stacktrace from asan: \n%s"
, stack.String()) |
| 294 } |
| 295 } |
| 296 } |
| 297 |
| 298 func TestParseGCSPackage_TimeOut(t *testing.T) { |
| 299 // Everything timed out on analysis |
| 300 g := GCSPackage{ |
| 301 Debug: OutputFiles{ |
| 302 Asan: testutils.MustReadFile(stacktrace("4bad_debug.as
an")), |
| 303 Dump: "", |
| 304 StdErr: testutils.MustReadFile(stacktrace("4bad_debug.er
r")), |
| 305 }, |
| 306 Release: OutputFiles{ |
| 307 Asan: testutils.MustReadFile(stacktrace("4bad_release.
asan")), |
| 308 Dump: "", |
| 309 StdErr: testutils.MustReadFile(stacktrace("4bad_release.
err")), |
| 310 }, |
| 311 FuzzCategory: "skcodec", |
| 312 } |
| 313 |
| 314 result := ParseGCSPackage(g) |
| 315 expectedDebugFlags := TimedOut |
| 316 expectedReleaseFlags := TimedOut |
| 317 if result.Debug.Flags != expectedDebugFlags { |
| 318 t.Errorf("Parsed Debug flags were wrong. Expected %s, but was %
s", expectedDebugFlags.String(), result.Debug.Flags.String()) |
| 319 } |
| 320 if result.Release.Flags != expectedReleaseFlags { |
| 321 t.Errorf("Parsed Release flags were wrong. Expected %s, but was
%s", expectedReleaseFlags.String(), result.Release.Flags.String()) |
| 322 } |
| 323 if !result.Debug.StackTrace.IsEmpty() { |
| 324 t.Errorf("Should have had empty debug stacktrace, but was %s", r
esult.Debug.StackTrace.String()) |
| 325 } |
| 326 if !result.Release.StackTrace.IsEmpty() { |
| 327 t.Errorf("Should have had empty release stacktrace, but was %s",
result.Release.StackTrace.String()) |
| 328 } |
| 329 } |
| 330 |
| 331 func TestParseGCSPackage_BadAlloc(t *testing.T) { |
| 332 // Everything was a bad:alloc |
| 333 g := GCSPackage{ |
| 334 Debug: OutputFiles{ |
| 335 Asan: testutils.MustReadFile(stacktrace("5bad_debug.as
an")), |
| 336 Dump: "", |
| 337 StdErr: testutils.MustReadFile(stacktrace("5bad_debug.er
r")), |
| 338 }, |
| 339 Release: OutputFiles{ |
| 340 Asan: testutils.MustReadFile(stacktrace("5bad_release.
asan")), |
| 341 Dump: "", |
| 342 StdErr: testutils.MustReadFile(stacktrace("5bad_release.
err")), |
| 343 }, |
| 344 FuzzCategory: "skcodec", |
| 345 } |
| 346 |
| 347 result := ParseGCSPackage(g) |
| 348 expectedDebugFlags := BadAlloc | ASANCrashed | ClangCrashed |
| 349 expectedReleaseFlags := BadAlloc | ASANCrashed | ClangCrashed |
| 350 if result.Debug.Flags != expectedDebugFlags { |
| 351 t.Errorf("Parsed Debug flags were wrong. Expected %s, but was %
s", expectedDebugFlags.String(), result.Debug.Flags.String()) |
| 352 } |
| 353 if result.Release.Flags != expectedReleaseFlags { |
| 354 t.Errorf("Parsed Release flags were wrong. Expected %s, but was
%s", expectedReleaseFlags.String(), result.Release.Flags.String()) |
| 355 } |
| 356 if result.Debug.StackTrace.IsEmpty() { |
| 357 t.Errorf("Should not have had empty debug stacktrace") |
| 358 } |
| 359 if result.Release.StackTrace.IsEmpty() { |
| 360 t.Errorf("Should not have had empty release stacktrace") |
| 361 } |
| 362 } |
| 363 |
| 364 func TestParseGCSPackage_EmptyStacktrace(t *testing.T) { |
| 365 // According to AddressSanitizer, both crashed while trying to report a
bug. |
| 366 g := GCSPackage{ |
| 367 Debug: OutputFiles{ |
| 368 Asan: testutils.MustReadFile(stacktrace("6bad_debug.as
an")), |
| 369 Dump: testutils.MustReadFile(stacktrace("6bad_debug.du
mp")), |
| 370 StdErr: testutils.MustReadFile(stacktrace("6bad_debug.er
r")), |
| 371 }, |
| 372 Release: OutputFiles{ |
| 373 Asan: testutils.MustReadFile(stacktrace("6bad_release.
asan")), |
| 374 Dump: testutils.MustReadFile(stacktrace("6bad_release.
dump")), |
| 375 StdErr: testutils.MustReadFile(stacktrace("6bad_release.
err")), |
| 376 }, |
| 377 FuzzCategory: "skcodec", |
| 378 } |
| 379 |
| 380 result := ParseGCSPackage(g) |
| 381 expectedDebugFlags := NoStackTrace | ASANCrashed | ClangCrashed |
| 382 expectedReleaseFlags := NoStackTrace | ASANCrashed | ClangCrashed |
| 383 if result.Debug.Flags != expectedDebugFlags { |
| 384 t.Errorf("Parsed Debug flags were wrong. Expected %s, but was %
s", expectedDebugFlags.String(), result.Debug.Flags.String()) |
| 385 } |
| 386 if result.Release.Flags != expectedReleaseFlags { |
| 387 t.Errorf("Parsed Release flags were wrong. Expected %s, but was
%s", expectedReleaseFlags.String(), result.Release.Flags.String()) |
| 388 } |
| 389 if !result.Debug.StackTrace.IsEmpty() { |
| 390 t.Errorf("Should have had empty debug stacktrace") |
| 391 } |
| 392 if !result.Release.StackTrace.IsEmpty() { |
| 393 t.Errorf("Should have had empty release stacktrace") |
| 394 } |
| 395 } |
| 396 |
| 397 func TestParseGCSPackage_SKAbort(t *testing.T) { |
| 398 // Both hit SK_ABORT somewhere. |
| 399 g := GCSPackage{ |
| 400 Debug: OutputFiles{ |
| 401 Asan: testutils.MustReadFile(stacktrace("7bad_debug.as
an")), |
| 402 Dump: "", |
| 403 StdErr: testutils.MustReadFile(stacktrace("7bad_debug.er
r")), |
| 404 }, |
| 405 Release: OutputFiles{ |
| 406 Asan: testutils.MustReadFile(stacktrace("7bad_release.
asan")), |
| 407 Dump: "", |
| 408 StdErr: testutils.MustReadFile(stacktrace("7bad_release.
err")), |
| 409 }, |
| 410 FuzzCategory: "skpicture", |
| 411 } |
| 412 |
| 413 result := ParseGCSPackage(g) |
| 414 expectedDebugFlags := SKAbortHit | ASANCrashed | ClangCrashed |
| 415 expectedReleaseFlags := SKAbortHit | ASANCrashed | ClangCrashed |
| 416 if result.Debug.Flags != expectedDebugFlags { |
| 417 t.Errorf("Parsed Debug flags were wrong. Expected %s, but was %
s", expectedDebugFlags.String(), result.Debug.Flags.String()) |
| 418 } |
| 419 if result.Release.Flags != expectedReleaseFlags { |
| 420 t.Errorf("Parsed Release flags were wrong. Expected %s, but was
%s", expectedReleaseFlags.String(), result.Release.Flags.String()) |
| 421 } |
| 422 if len(result.Debug.StackTrace.Frames) != 1 { |
| 423 t.Fatalf("Should have filled in top frame of trace") |
| 424 } |
| 425 expected := FullStackFrame("src/core/", "SkPictureData.cpp", common.UNKN
OWN_FUNCTION, 360) |
| 426 if frame := result.Debug.StackTrace.Frames[0]; frame.LineNumber != expec
ted.LineNumber || frame.FunctionName != expected.FunctionName || frame.FileName
!= expected.FileName || frame.PackageName != expected.PackageName { |
| 427 t.Errorf("Top frame was wrong. Expected: %#v, but was %#v", exp
ected, frame) |
| 428 } |
| 429 |
| 430 if len(result.Release.StackTrace.Frames) != 1 { |
| 431 t.Errorf("Should not have had empty release stacktrace") |
| 432 } |
| 433 if frame := result.Release.StackTrace.Frames[0]; frame.LineNumber != exp
ected.LineNumber || frame.FunctionName != expected.FunctionName || frame.FileNam
e != expected.FileName || frame.PackageName != expected.PackageName { |
| 434 t.Errorf("Top frame was wrong. Expected: %#v, but was %#v", exp
ected, frame) |
| 435 } |
| 436 } |
OLD | NEW |