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

Unified Diff: appengine/findit/crash/test/callstack_filters_test.py

Issue 2588133003: [Predator] Add clusterfuzz callstack filters. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: appengine/findit/crash/test/callstack_filters_test.py
diff --git a/appengine/findit/crash/test/callstack_filters_test.py b/appengine/findit/crash/test/callstack_filters_test.py
index 4537c694253505c10b3a0ffbf3bb031e07e0652c..60336f9a26651240f5832531d99743e9265a7f4a 100644
--- a/appengine/findit/crash/test/callstack_filters_test.py
+++ b/appengine/findit/crash/test/callstack_filters_test.py
@@ -2,30 +2,32 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from crash import callstack_filters
from crash.stacktrace import StackFrame
from crash.stacktrace import CallStackBuffer
-from crash import callstack_filters
from crash.test.stacktrace_test_suite import StacktraceTestSuite
+from crash.type_enums import LanguageType
-class CallStackFiltersTest(StacktraceTestSuite):
+class FilterInlineFunctionTest(StacktraceTestSuite):
+ """Tests that ``FilterInlineFunction`` works as expected."""
- def testFilterInlineFunction(self):
- """Tests ``FilterInlineFunction`` filters all inline function frames."""
+ def testFilterInlineFunctions(self):
+ """Tests filtering all inline function frames."""
frame_list = [
StackFrame(
0, 'src/', 'normal_func', 'f.cc', 'dummy/src/f.cc', [2]),
StackFrame(
- 0, 'src/', 'inline_func',
+ 1, 'src/', 'inline_func',
'third_party/llvm-build/Release+Asserts/include/c++/v1/a',
'src/third_party/llvm-build/Release+Asserts/include/c++/v1/a', [1]),
StackFrame(
- 0, 'src/', 'inline_func',
+ 2, 'src/', 'inline_func',
'linux/debian_wheezy_amd64-sysroot/usr/include/c++/4.6/bits/b',
'src/linux/debian_wheezy_amd64-sysroot/usr/include/c++/4.6/bits/b',
[1]),
StackFrame(
- 0, 'src/', 'inline_func',
+ 3, 'src/', 'inline_func',
'eglibc-3GlaMS/eglibc-2.19/sysdeps/unix/c',
'src/eglibc-3GlaMS/eglibc-2.19/sysdeps/unix/c', [1])
]
@@ -37,13 +39,17 @@ class CallStackFiltersTest(StacktraceTestSuite):
CallStackBuffer(0, frame_list=frame_list)),
CallStackBuffer(0, frame_list=expected_frame_list))
+
+class KeepTopNFramesTest(StacktraceTestSuite):
+ """Tests ``KeepTopNFrames`` works as expected."""
wrengr 2016/12/19 23:51:06 "tests ``..." -> "tests that ``..."
Sharu Jiang 2016/12/22 01:59:44 Done. I omitted the "that" to save space, guess I
+
def testKeepTopNFrames(self):
- """Tests ``KeepTopNFrames`` only keeps the top n frames of a callstack."""
+ """Tests keeping the top n frames of a callstack."""
frame_list = [
StackFrame(
0, 'src/', 'normal_func', 'f.cc', 'dummy/src/f.cc', [2]),
StackFrame(
- 0, 'src/', 'func', 'a.cc', 'a.cc', [1]),
+ 1, 'src/', 'func', 'a.cc', 'a.cc', [1]),
]
top_n = 1
@@ -52,15 +58,253 @@ class CallStackFiltersTest(StacktraceTestSuite):
CallStackBuffer(0, frame_list=frame_list)),
CallStackBuffer(0, frame_list=frame_list[:top_n]))
- def testKeepTopNFramesDoNothingForNonTopNFrames(self):
- """Tests ``KeepTopNFrames`` does nothing if top_n_frames is None"""
+ def testDoNothingIfTopNFramesFieldIsEmpty(self):
+ """Tests if top_n_frames is None, filter does nothing."""
wrengr 2016/12/19 23:51:06 "tests if" -> "tests that if"
Sharu Jiang 2016/12/22 01:59:43 Done.
frame_list = [
StackFrame(
0, 'src/', 'normal_func', 'f.cc', 'dummy/src/f.cc', [2]),
StackFrame(
- 0, 'src/', 'func', 'a.cc', 'a.cc', [1]),
+ 1, 'src/', 'func', 'a.cc', 'a.cc', [1]),
]
stack_buffer = CallStackBuffer(0, frame_list=frame_list)
self._VerifyTwoCallStacksEqual(
callstack_filters.KeepTopNFrames()(stack_buffer), stack_buffer)
+
+
+class FilterJavaJreSdkFramesTest(StacktraceTestSuite):
+ """Tests ``FilterJavaJreSdkFrames`` works as expected."""
wrengr 2016/12/19 23:51:06 "tests ``..." -> "tests that ``..."
Sharu Jiang 2016/12/22 01:59:44 Done.
+
+ def testDoNothingForNonJavaStack(self):
+ """Tests the filter does nothing for non-java stack."""
wrengr 2016/12/19 23:51:06 "tests the" -> "tests that the"
Sharu Jiang 2016/12/22 01:59:43 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/', 'normal_func', 'f.cc', 'dummy/src/f.cc', [2])
+ ]
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list,
+ language_type=LanguageType.CPP)
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterJavaJreSdkFrames()(stack_buffer), stack_buffer)
+
+ def testFilterJavaJreSdkFramesForJavaStack(self):
+ """Tests filter java JRE/SDK frames for java stack."""
+ frame_list = [
+ StackFrame(
+ 0, 'an/', 'javax.f', 'javax/f.java', 'javax/f.java', [2]),
+ StackFrame(
+ 1, 'an/', 'org.omg.a', 'org/omg/a.java', 'org/omg/a.java', [2]),
+ StackFrame(0, 'an/', 'an.b', 'an/b.java', 'an/b.java', [12, 13]),
+ ]
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list,
+ language_type=LanguageType.JAVA)
+ expected_stack_buffer = CallStackBuffer(0, frame_list=frame_list[2:],
+ language_type=LanguageType.JAVA)
+
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterJavaJreSdkFrames()(stack_buffer),
+ expected_stack_buffer)
+
+
+class KeepV8FramesIfV8GeneratedJITCrashTest(StacktraceTestSuite):
+ """Tests ``KeepV8FramesIfV8GeneratedJITCrash`` works as expected."""
wrengr 2016/12/19 23:51:06 "tests ``..." -> "tests that ``..."
Sharu Jiang 2016/12/22 01:59:43 Done.
+
+ def testKeepV8FramesIfV8GeneratedJITCrash(self):
+ """Tests ``KeepV8FramesIfV8GeneratedJITCrash`` keeps v8 frames."""
wrengr 2016/12/19 23:51:06 "tests ``..." -> "tests that ``..."
Sharu Jiang 2016/12/22 01:59:44 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'v8::internal::Invoke', 'f.cc', 'dummy/src/f.cc', [2]),
+ StackFrame(
+ 1, 'src/v8', 'func', 'a.cc', 'a.cc', [1]),
+ StackFrame(
+ 2, 'src', 'func', 'b.cc', 'b.cc', [2, 3]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list,
+ metadata={'top_frame_has_no_symbols': True})
+ expected_stack_buffer = CallStackBuffer(
+ 0, frame_list=frame_list[:2],
+ metadata={'top_frame_has_no_symbols': True})
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.KeepV8FramesIfV8GeneratedJITCrash()(stack_buffer),
+ expected_stack_buffer)
+
+ def testDoNothingForNonV8GeneratedJITCrash(self):
+ """Tests filter does nothing for non v8 generated JIT crash."""
wrengr 2016/12/19 23:51:06 "tests filter" -> tests that filter(ing)"
Sharu Jiang 2016/12/22 01:59:44 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'a.cc', 'a.cc', [1]),
+ StackFrame(
+ 1, 'src', 'func', 'b.cc', 'b.cc', [2, 3]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list,
+ metadata={'top_frame_has_no_symbols': True})
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.KeepV8FramesIfV8GeneratedJITCrash()(stack_buffer),
+ stack_buffer)
+
+
+class FilterV8FramesForV8APIBindingCodeTest(StacktraceTestSuite):
+ """Tests ``FilterV8FramesForV8APIBindingCode`` works as expected."""
wrengr 2016/12/19 23:51:06 "tests ``..." -> "tests that ``..."
Sharu Jiang 2016/12/22 01:59:43 Done.
+
+ def testDoNothingForStackWithLessThanTwoFrames(self):
+ """Tests filtering nothing if the stack has less than two frames."""
wrengr 2016/12/19 23:51:06 "tests filtering nothing" -> "tests that filter(in
Sharu Jiang 2016/12/22 01:59:44 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'a.cc', 'a.cc', [1]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterV8FramesForV8APIBindingCode()(
+ stack_buffer),
+ stack_buffer)
+
+ def testFilterV8FramesForV8APIBindingBlinkCode(self):
+ """Tests filtering V8 frames form V8 binding blink code."""
wrengr 2016/12/19 23:51:06 "form" -> from"
Sharu Jiang 2016/12/22 01:59:44 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'src/api.h', 'src/api.h', [1]),
+ StackFrame(
+ 1, 'src/', 'func', 'out/Release/gen/blink/bindings/a.cc',
+ 'out/Release/gen/blink/bindings/a.cc', [1]),
+ StackFrame(
+ 2, 'src', 'func', 'a.cc', 'a.cc', [1]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ expected_stack_buffer = CallStackBuffer(0, frame_list=frame_list[2:])
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterV8FramesForV8APIBindingCode()(stack_buffer),
+ expected_stack_buffer)
+
+ def testFilterAllFramesForNullPointerDereference(self):
+ """Tests filtering all frames for null pointer dereference stack."""
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'src/api.h', 'src/api.h', [1]),
+ StackFrame(
+ 2, 'src/v8', 'func', 'a.cc', 'a.cc', [1]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ expected_stack_buffer = CallStackBuffer(0, frame_list=[])
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterV8FramesForV8APIBindingCode('0x0000')(
+ stack_buffer),
+ expected_stack_buffer)
+
+ def testFilterV8FramesForNullPointerDereference(self):
+ """Tests filtering all v8 frames for null pointer dereference stack."""
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'src/api.h', 'src/api.h', [1]),
+ StackFrame(
+ 2, 'src', 'func', 'a.cc', 'a.cc', [1]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ expected_stack_buffer = CallStackBuffer(0, frame_list=frame_list[1:])
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterV8FramesForV8APIBindingCode('0x0000')(
+ stack_buffer),
+ expected_stack_buffer)
+
+ def testDoNothingForNonV8APIBindingStack(self):
+ """Tests filtering nothing for non v8 api binding stack."""
wrengr 2016/12/19 23:51:06 "tests filtering nothing" -> "tests that filter(in
Sharu Jiang 2016/12/22 01:59:44 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'f.cc', 'f.cc', [1]),
+ StackFrame(
+ 2, 'src', 'func', 'a.cc', 'a.cc', [1]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterV8FramesForV8APIBindingCode()(
+ stack_buffer),
+ stack_buffer)
+
+
+class FilterFramesAfterBlinkGeneratedCode(StacktraceTestSuite):
+ """Tests ``FilterFramesAfterBlinkGeneratedCode`` works as expected."""
wrengr 2016/12/19 23:51:06 "tests ``..." -> "tests that ``..."
+
+ def testDoNothingIfNoBlinkBindingGeneratedCode(self):
+ """Tests filtering nothing if there is no blink binding generated code."""
wrengr 2016/12/19 23:51:06 "tests filtering nothing" -> "tests that filter(in
Sharu Jiang 2016/12/22 01:59:43 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'a.cc', 'a.cc', [1]),
+ StackFrame(
+ 1, 'src', 'func', 'b.cc', 'b.cc', [2, 3]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterFramesAfterBlinkGeneratedCode()(stack_buffer),
+ stack_buffer)
+
+ def testFilterFramesAfterBlinkBindingGeneratedCode(self):
+ """Tests filtering nothing if there is no blink binding generated code."""
wrengr 2016/12/19 23:51:06 "tests filtering nothing" -> "tests that filter(in
Sharu Jiang 2016/12/22 01:59:43 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'a.cc', 'a.cc', [1]),
+ StackFrame(
+ 1, 'src/', 'func', 'out/Release/gen/blink/bindings/a.cc',
+ 'out/Release/gen/blink/bindings/a.cc', [1]),
+ StackFrame(
+ 2, 'src', 'func', 'b.cc', 'b.cc', [2, 3]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ expected_stack_buffer = CallStackBuffer(0, frame_list=frame_list[:1])
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterFramesAfterBlinkGeneratedCode()(stack_buffer),
+ expected_stack_buffer)
+
+
+class FilterV8FramesIfV8notInTopFramesTest(StacktraceTestSuite):
+ """Tests ``FilterV8FramesIfV8NotInTopFrames`` works as expected."""
wrengr 2016/12/19 23:51:06 "tests ``..." -> "tests that ``..."
Sharu Jiang 2016/12/22 01:59:44 Done.
+
+ def testFilterV8FrameIfV8notInTopFrames(self):
+ """Tests filtering v8 frames if there is no v8 frame in top frames."""
wrengr 2016/12/19 23:51:06 unclear
Sharu Jiang 2016/12/22 01:59:44 I tried to explain this in one line... it seems th
+ frame_list = [
+ StackFrame(
+ 0, 'src', 'func', 'a.cc', 'a.cc', [1]),
+ StackFrame(
+ 1, 'src', 'func', 'b.cc', 'b.cc', [1]),
+ StackFrame(
+ 2, 'src', 'func', 'c.cc', 'c.cc', [2, 3]),
+ StackFrame(
+ 3, 'src/v8', 'func', 'd.cc', 'd.cc', [1]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ expected_stack_buffer = CallStackBuffer(0, frame_list=frame_list[:3])
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterV8FramesIfV8NotInTopFrames(2)(stack_buffer),
+ expected_stack_buffer)
+
+ def testDoNothingIfV8InTopFrames(self):
+ """Tests filtering nothing if there is v8 frame in top frames."""
wrengr 2016/12/19 23:51:06 "tests filtering nothing" -> "tests that filter(in
Sharu Jiang 2016/12/22 01:59:43 Done.
+ frame_list = [
+ StackFrame(
+ 0, 'src/v8', 'func', 'a.cc', 'a.cc', [1]),
+ StackFrame(
+ 1, 'src', 'func', 'b.cc', 'b.cc', [1]),
+ StackFrame(
+ 2, 'src', 'func', 'c.cc', 'c.cc', [2, 3]),
+ StackFrame(
+ 3, 'src/v8', 'func', 'd.cc', 'd.cc', [1]),
+ ]
+
+ stack_buffer = CallStackBuffer(0, frame_list=frame_list)
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterV8FramesIfV8NotInTopFrames(2)(stack_buffer),
+ stack_buffer)
+
+ def testDoNothingForEmptyStackBuffer(self):
+ """Tests filtering nothing for empty stack buffer."""
wrengr 2016/12/19 23:51:06 "tests filtering nothing" -> "tests that filter(in
Sharu Jiang 2016/12/22 01:59:43 Done.
+ stack_buffer = CallStackBuffer(0, frame_list=[])
+ self._VerifyTwoCallStacksEqual(
+ callstack_filters.FilterV8FramesIfV8NotInTopFrames(2)(stack_buffer),
+ stack_buffer)
« appengine/findit/crash/callstack_filters.py ('K') | « appengine/findit/crash/stacktrace.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698