| 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..67a0487a8e4a0671e741b9fdd31585860dc9a62f 100644
|
| --- a/appengine/findit/crash/test/callstack_filters_test.py
|
| +++ b/appengine/findit/crash/test/callstack_filters_test.py
|
| @@ -5,27 +5,31 @@
|
| from crash.stacktrace import StackFrame
|
| from crash.stacktrace import CallStackBuffer
|
| from crash import callstack_filters
|
| +from crash.stacktrace import StackFrame
|
| +from crash.stacktrace import CallStackBuffer
|
| 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 that 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 +41,17 @@ class CallStackFiltersTest(StacktraceTestSuite):
|
| CallStackBuffer(0, frame_list=frame_list)),
|
| CallStackBuffer(0, frame_list=expected_frame_list))
|
|
|
| +
|
| +class KeepTopNFramesTest(StacktraceTestSuite):
|
| + """Tests that ``KeepTopNFrames`` works as expected."""
|
| +
|
| def testKeepTopNFrames(self):
|
| - """Tests ``KeepTopNFrames`` only keeps the top n frames of a callstack."""
|
| + """Tests that 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 +60,256 @@ 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 that if top_n_frames is None, filter does nothing."""
|
| 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 that ``FilterJavaJreSdkFrames`` works as expected."""
|
| +
|
| + def testDoNothingForNonJavaStack(self):
|
| + """Tests that the filter does nothing for non-java stack."""
|
| + 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 that 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 that ``KeepV8FramesIfV8GeneratedJITCrash`` works as expected."""
|
| +
|
| + def testKeepV8FramesIfV8GeneratedJITCrash(self):
|
| + """Tests that ``KeepV8FramesIfV8GeneratedJITCrash`` keeps v8 frames."""
|
| + 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 that filter does nothing for non v8 generated JIT crash."""
|
| + 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 that ``FilterV8FramesForV8APIBindingCode`` works as expected."""
|
| +
|
| + def testDoNothingForStackWithLessThanTwoFrames(self):
|
| + """Tests that filter nothing if the stack has less than two frames."""
|
| + 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 that filter V8 frames from V8 binding blink code."""
|
| + 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 that 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 that 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 that filter does nothing for non v8 api binding stack."""
|
| + 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 that ``FilterFramesAfterBlinkGeneratedCode`` works as expected."""
|
| +
|
| + def testDoNothingIfNoBlinkBindingGeneratedCode(self):
|
| + """Tests that filter does nothing if no blink binding generated code."""
|
| + 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 that filter does nothing if no blink binding generated code."""
|
| + 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 that ``FilterV8FramesIfV8NotInTopFrames`` works as expected."""
|
| +
|
| + def testFilterV8FrameIfV8notInTopFrames(self):
|
| + """Tests filtering all v8 frames when condition met.
|
| +
|
| + If there is no v8 frame in top n frames, the crash should not be caused by
|
| + v8 cls, filter all the remaining v8 frames in the stack."""
|
| + 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 that filter does nothing if there is v8 frame in top frames."""
|
| + 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 that filter does nothing for empty stack buffer."""
|
| + stack_buffer = CallStackBuffer(0, frame_list=[])
|
| + self._VerifyTwoCallStacksEqual(
|
| + callstack_filters.FilterV8FramesIfV8NotInTopFrames(2)(stack_buffer),
|
| + stack_buffer)
|
|
|