def test_base_with_env_args(self): """Test base's reproduce_crash with environment args.""" mocked_testcase = mock.Mock( id=1234, reproduction_args='--app-dir=%APP_DIR% --testcase=%TESTCASE%', environment={'ASAN_OPTIONS': 'test-asan'}, gestures=None, stacktrace_lines=[{ 'content': 'line' }], job_type='job_type') mocked_testcase.get_testcase_path.return_value = self.testcase_path mocked_provider = mock.Mock(symbolizer_path='%s/llvm-symbolizer' % self.app_directory) mocked_provider.get_binary_path.return_value = '%s/d8' % self.app_directory mocked_provider.get_build_directory.return_value = self.app_directory reproducer = reproducers.BaseReproducer(mocked_provider, mocked_testcase, 'UBSAN', False, '--test', False) reproducer.setup_args() reproducer.reproduce_crash() self.assert_exact_calls(self.mock.execute, [ mock.call('/chrome/source/folder/d8', '--app-dir=%s --testcase=%s --test' % (self.app_directory, self.testcase_path), '/chrome/source/folder', env={'ASAN_OPTIONS': 'test-asan'}, exit_on_error=False) ])
def test_base(self): """Test base's reproduce_crash.""" mocked_testcase = mock.Mock(id=1234, reproduction_args='--repro', environment={'ASAN_OPTIONS': 'test-asan'}, gestures=None, stacktrace_lines=[{ 'content': 'line' }], job_type='job_type') mocked_testcase.get_testcase_path.return_value = self.testcase_path mocked_provider = mock.Mock(symbolizer_path='%s/llvm-symbolizer' % self.app_directory) mocked_provider.get_binary_path.return_value = '%s/d8' % self.app_directory mocked_provider.get_build_directory.return_value = self.app_directory reproducer = reproducers.BaseReproducer( self.definition, mocked_provider, mocked_testcase, 'UBSAN', libs.make_options(target_args='--test')) reproducer.setup_args() reproducer.reproduce_crash() self.assert_exact_calls(self.mock.execute, [ mock.call('/chrome/source/folder/d8', '--repro --test %s' % self.testcase_path, '/chrome/source/folder', env={'ASAN_OPTIONS': 'test-asan'}, exit_on_error=False, timeout=30, stdout_transformer=mock.ANY, redirect_stderr_to_stdout=True) ])
def setUp(self): self.binary_provider = mock.Mock(symbolizer_path='/path/to/symbolizer') self.testcase = mock.Mock(gestures=None, stacktrace_lines=[{ 'content': 'line' }], job_type='job_type', reproduction_args='--orig') self.reproducer = reproducers.BaseReproducer(self.binary_provider, self.testcase, 'UBSAN', False, '--test', False)
def test_set_up_correct_env(self): """Ensures all the setup methods work correctly.""" root_path = '/fake' self.fs.CreateFile('/fake/resources/llvm-symbolizer', contents='t') self.fs.CreateFile( '/fake/resources/suppressions/lsan_suppressions.txt', contents='t') self.fs.CreateFile( '/fake/resources/suppressions/ubsan_suppressions.txt', contents='t') def get(_, *paths): return os.path.join(root_path, *paths) self.mock.get_resource.side_effect = get self.binary_provider = mock.Mock() self.definition = mock.Mock() self.testcase = mock.Mock( gestures=None, stacktrace_lines=[{ 'content': 'line' }], job_type='job_type', reproduction_args='--orig') self.reproducer = reproducers.BaseReproducer( self.definition, self.binary_provider, self.testcase, 'UBSAN', libs.make_options(target_args='--test')) self.reproducer.environment = { 'UBSAN_OPTIONS': ('external_symbolizer_path=/not/correct/path:other_' 'option=1:suppressions=/not/correct/path:' 'coverage_dir=test'), 'CFI_OPTIONS': ('external_symbolizer_path=/not/correct/path:other_' 'option=1:suppressions=/not/correct/path'), 'LSAN_OPTIONS': 'other=0:suppressions=not/correct/path:option=1' } self.reproducer.set_up_symbolizers_suppressions() result = self.reproducer.environment for i in result: if '_OPTIONS' in i: result[i] = reproducers.deserialize_sanitizer_options(result[i]) self.assertEqual( result, { 'UBSAN_OPTIONS': { 'external_symbolizer_path': '%s/resources/llvm-symbolizer' % root_path, 'other_option': '1', 'suppressions': ( '%s/resources/suppressions/ubsan_suppressions.txt' % root_path) }, 'CFI_OPTIONS': { 'external_symbolizer_path': '%s/resources/llvm-symbolizer' % root_path, 'other_option': '1', 'suppressions': ( '%s/resources/suppressions/ubsan_suppressions.txt' % root_path) }, 'LSAN_OPTIONS': { 'other': '0', 'suppressions': ( '%s/resources/suppressions/lsan_suppressions.txt' % root_path), 'option': '1' }, 'UBSAN_SYMBOLIZER_PATH': '%s/resources/llvm-symbolizer' % root_path, 'DISPLAY': ':0.0' })