1#!/usr/bin/env python3 2# 3# Copyright (C) 2021 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17from typing import List 18 19from . test_utils import TestBase, TestHelper 20 21 22class TestDebugUnwindReporter(TestBase): 23 def run_reporter(self, options: List[str]) -> str: 24 report_file = TestHelper.testdata_dir / 'debug_unwind_report.txt' 25 return self.run_cmd(['debug_unwind_reporter.py', '-i', 26 str(report_file)] + options, return_output=True) 27 28 def test_show_callchain_fixed_by_joiner_option(self): 29 output = self.run_reporter([]) 30 self.assertFalse('__start_thread' in output) 31 output = self.run_reporter(['--show-callchain-fixed-by-joiner']) 32 self.assertTrue('__start_thread' in output) 33 34 def test_summary_option(self): 35 output = self.run_reporter(['--summary']) 36 self.assertTrue('Error Code' in output) 37 38 def test_error_code_filter_options(self): 39 output = self.run_reporter(['--exclude-error-code', '1']) 40 self.assertFalse('sample_time: 626968109563718' in output) 41 output = self.run_reporter( 42 ['--include-error-code', '4', '--show-callchain-fixed-by-joiner']) 43 self.assertFalse('sample_time: 626968109563718' in output) 44 self.assertTrue('sample_time: 626970513562864' in output) 45 46 def test_end_dso_filter_options(self): 47 output = self.run_reporter( 48 ['--exclude-end-dso', '/apex/com.android.runtime/lib64/bionic/libc.so']) 49 self.assertFalse('sample_time: 626968109563718' in output) 50 output = self.run_reporter( 51 ['--include-end-dso', '/apex/com.android.runtime/lib64/bionic/libc.so']) 52 self.assertTrue('sample_time: 626968109563718' in output) 53 54 def test_end_symbol_filter_options(self): 55 output = self.run_reporter(['--exclude-end-symbol', 'clone']) 56 self.assertFalse('sample_time: 626968109563718' in output) 57 output = self.run_reporter( 58 ['--include-end-symbol', '__start_thread', '--show-callchain-fixed-by-joiner']) 59 self.assertFalse('sample_time: 626968109563718' in output) 60 self.assertTrue('sample_time: 626970513562864' in output) 61 62 def test_sample_time_filter_options(self): 63 output = self.run_reporter(['--exclude-sample-time', '626968109563718']) 64 self.assertFalse('sample_time: 626968109563718' in output) 65 output = self.run_reporter( 66 ['--include-sample-time', '626970513562864', '--show-callchain-fixed-by-joiner']) 67 self.assertFalse('sample_time: 626968109563718' in output) 68 self.assertTrue('sample_time: 626970513562864' in output) 69