Пример #1
0
  def test_deserialize(self):
    out_dict = {
        'suppressions': '/a/b/c/d/suppresions.txt',
        'option': '1',
        'symbolizer': 'abcde/llvm-symbolizer'
    }
    in_str = ('suppressions=/a/b/c/d/suppresions.txt:option=1'
              ':symbolizer=abcde/llvm-symbolizer')

    self.assertEqual(
        reproducers.deserialize_sanitizer_options(in_str), out_dict)
Пример #2
0
  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'
        })