Ejemplo n.º 1
0
 def test_set_build_dir(self):
     host = Host()
     with self.assertRaises(Host.ConfigError):
         host.set_fuzzers_json('no_such_build_dir')
     if not os.getenv('FUCHSIA_DIR'):
         return
     build_dir = host.find_build_dir()
     ssh_config = Host.join(build_dir, 'ssh-keys', 'ssh_config')
     zxtools = Host.join(build_dir + '.zircon', 'tools')
     platform = 'mac-x64' if os.uname()[0] == 'Darwin' else 'linux-x64'
     executable = Host.join(host.get_host_out_dir(), 'symbolize')
     symbolizer = Host.join(
         'prebuilt',
         'third_party',
         'clang',
         platform,
         'bin',
         'llvm-symbolizer',
     )
     host.set_build_dir(build_dir)
     self.assertNotEqual(len(host._ids), 0)
     for id in host._ids:
         self.assertTrue(os.path.exists(id))
     self.assertIsNotNone(host._zxtools)
     self.assertTrue(os.path.exists(host._symbolizer_exec))
     self.assertTrue(os.path.exists(host._llvm_symbolizer))
Ejemplo n.º 2
0
 def test_join(self):
     fuchsia_dir = os.getenv('FUCHSIA_DIR')
     os.unsetenv('FUCHSIA_DIR')
     del os.environ['FUCHSIA_DIR']
     with self.assertRaises(Host.ConfigError):
         Host.join('foo')
     if not fuchsia_dir:
         return
     os.environ['FUCHSIA_DIR'] = fuchsia_dir
     self.assertTrue(Host.join('foo').endswith('foo'))
Ejemplo n.º 3
0
 def test_set_fuzzers_json(self):
     host = Host()
     with self.assertRaises(Host.ConfigError):
         host.set_fuzzers_json('no_such_json')
     if not os.getenv('FUCHSIA_DIR'):
         return
     build_dir = host.find_build_dir()
     json_file = Host.join(build_dir, 'fuzzers.json')
     # No guarantee of contents; just ensure it parses without crashing.
     if os.path.exists(json_file):
         host.set_fuzzers_json(json_file)
     # Construct and parse both fuchisa and zircon style fuzzer metadata.
     data = [
         {
             'fuzz_host': False,
             'fuzzers': ['foo_fuzzer'],
             'fuzzers_package': 'foo_fuzzers'
         },
         {
             'fuzz_host': False,
             'fuzzers': ['zx_fuzzer.asan', 'zx_fuzzer.ubsan'],
             'fuzzers_package': 'zircon_fuzzers'
         },
     ]
     with tempfile.NamedTemporaryFile() as f:
         f.write(json.dumps(data))
         f.seek(0)
         host.set_fuzzers_json(f.name)
         self.assertIn(('foo_fuzzers', 'foo_fuzzer'), host.fuzzers)
         self.assertIn(('zircon_fuzzers', 'zx_fuzzer.asan'), host.fuzzers)
         self.assertIn(('zircon_fuzzers', 'zx_fuzzer.ubsan'), host.fuzzers)
Ejemplo n.º 4
0
 def test_set_symbolizer(self):
     host = Host()
     with self.assertRaises(Host.ConfigError):
         host.set_symbolizer('no_such_executable', 'no_such_symbolizer')
     if not os.getenv('FUCHSIA_DIR'):
         return
     platform = 'mac-x64' if os.uname()[0] == 'Darwin' else 'linux-x64'
     executable = Host.join(host.get_host_out_dir(), 'symbolize')
     symbolizer = Host.join('prebuilt', 'third_party', 'clang', platform,
                            'bin', 'llvm-symbolizer')
     with self.assertRaises(Host.ConfigError):
         host.set_symbolizer(executable, 'no_such_symbolizer')
     with self.assertRaises(Host.ConfigError):
         host.set_symbolizer('no_such_executable', symbolizer)
     host.set_symbolizer(executable, symbolizer)
     self.assertEqual(host._symbolizer_exec, executable)
     self.assertEqual(host._llvm_symbolizer, symbolizer)
Ejemplo n.º 5
0
 def test_set_zxtools(self):
     host = Host()
     with self.assertRaises(Host.ConfigError):
         host.set_zxtools('no_such_zxtools')
     if not os.getenv('FUCHSIA_DIR'):
         return
     build_dir = host.find_build_dir()
     zxtools = Host.join(build_dir + '.zircon', 'tools')
     if not os.path.isdir(zxtools):
         return
     host.set_zxtools(zxtools)
     self.assertEqual(host._zxtools, zxtools)
Ejemplo n.º 6
0
 def test_add_build_ids(self):
     host = Host()
     host.add_build_ids('no_such_ids')
     self.assertNotIn('no_such_ids', host._ids)
     if not os.getenv('FUCHSIA_DIR'):
         return
     build_dir = host.find_build_dir()
     build_ids = Host.join(build_dir, '.build-id')
     if not os.path.exists(build_ids):
         return
     host.add_build_ids(build_ids)
     self.assertIn(build_ids, host._ids)
Ejemplo n.º 7
0
 def test_set_build_ids(self):
     host = Host()
     with self.assertRaises(Host.ConfigError):
         host.set_build_ids('no_such_ids')
     if not os.getenv('FUCHSIA_DIR'):
         return
     build_dir = host.find_build_dir()
     build_ids = Host.join(build_dir, 'ids.txt')
     if not os.path.exists(build_ids):
         return
     host.set_build_ids(build_ids)
     self.assertEqual(host._ids, build_ids)
Ejemplo n.º 8
0
 def test_set_fuzzers_json(self):
     host = Host()
     with self.assertRaises(Host.ConfigError):
         host.set_fuzzers_json('no_such_json')
     if not os.getenv('FUCHSIA_DIR'):
         return
     build_dir = host.find_build_dir()
     json_file = Host.join(build_dir, 'fuzzers.json')
     if not os.path.exists(json_file):
         return
     # No guarantee of contents; just ensure it parses without crashing
     host.set_fuzzers_json(json_file)
Ejemplo n.º 9
0
 def test_set_ssh_identity(self):
     mock = MockDevice()
     with self.assertRaises(Host.ConfigError):
         mock.set_ssh_identity('no_such_identity')
     if not os.getenv('FUCHSIA_DIR'):
         return
     identity_file = Host.join('.ssh', 'pkey')
     if not os.path.exists(identity_file):
         return
     mock.set_ssh_identity(identity_file)
     cmd = ' '.join(mock.get_ssh_cmd(['scp']))
     self.assertIn('scp', cmd)
     self.assertIn(' -i ' + identity_file, cmd)
Ejemplo n.º 10
0
 def test_set_ssh_config(self):
     mock = MockDevice()
     with self.assertRaises(Host.ConfigError):
         mock.set_ssh_config('no_such_config')
     if not os.getenv('FUCHSIA_DIR'):
         return
     build_dir = mock.host.find_build_dir()
     ssh_config = Host.join(build_dir, 'ssh-keys', 'ssh_config')
     if not os.path.exists(ssh_config):
         return
     mock.set_ssh_config(ssh_config)
     cmd = ' '.join(mock.get_ssh_cmd(['ssh']))
     self.assertIn('ssh', cmd)
     self.assertIn(' -F ' + ssh_config, cmd)
Ejemplo n.º 11
0
 def __init__(self, fuzzer, disabled=False, root=None, label=None):
     self.disabled = disabled
     if disabled:
         return
     self.device = fuzzer.device
     self.fuzzer = fuzzer
     self._bin = Host.join('.jiri_root', 'bin', 'cipd')
     if root:
         self.root = root
         self._is_tmp = False
     else:
         self.root = tempfile.mkdtemp()
         self._is_tmp = True
     self.label = label
Ejemplo n.º 12
0
 def test_set_build_dir(self):
     host = Host()
     with self.assertRaises(Host.ConfigError):
         host.set_fuzzers_json('no_such_build_dir')
     if not os.getenv('FUCHSIA_DIR'):
         return
     build_dir = host.find_build_dir()
     ssh_config = Host.join(build_dir, 'ssh-keys', 'ssh_config')
     build_ids = Host.join(build_dir, 'ids.txt')
     zxtools = Host.join(build_dir + '.zircon', 'tools')
     platform = 'mac-x64' if os.uname()[0] == 'Darwin' else 'linux-x64'
     executable = Host.join('zircon', 'prebuilt', 'downloads', 'symbolize')
     symbolizer = Host.join('buildtools', platform, 'clang', 'bin',
                            'llvm-symbolizer')
     if not os.path.exists(ssh_config) or not os.path.exists(
             build_ids) or not os.path.isdir(zxtools):
         return
     host.set_build_dir(build_dir)
     self.assertEqual(host._ids, build_ids)
     self.assertEqual(host._zxtools, zxtools)
     self.assertEqual(host._platform, platform)
     self.assertEqual(host._symbolizer_exec, executable)
     self.assertEqual(host._llvm_symbolizer, symbolizer)
Ejemplo n.º 13
0
 def test_fx_command(self):
     mock = MockHost()
     mock.fx_command(['device-finder',  'list'])
     fx_bin = Host.join('.jiri_root', 'bin', 'fx')
     self.assertIn('{} device-finder list'.format(fx_bin), mock.history)