def test_notify_user(self): host = Host() try: host.set_build_dir(host.find_build_dir()) except Host.ConfigError: return host.notify_user('This is a test', 'This is only a test.')
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))
def test_zircon_tool(self): # If a build tree is available, try using a zircon tool for "real". host = Host() try: host.set_build_dir(host.find_build_dir()) except Host.ConfigError: return with self.assertRaises(Host.ConfigError): host.zircon_tool(['no_such_tool']) path = os.path.abspath(__file__) line = host.zircon_tool(['merkleroot', path]) self.assertRegexpMatches(line, r'[0-9a-f]* - ' + path)
def test_symbolize(self): mock = MockHost() mock.symbolize('mock_in', 'mock_out') self.assertIn( 'mock/symbolize-ids-rel -ids mock/ids.txt -llvm-symbolizer mock/llvm_symbolizer', mock.history) # If a build tree is available, try doing symbolize for "real". host = Host() try: host.set_build_dir(host.find_build_dir()) except Host.ConfigError: return tmp_in = tempfile.TemporaryFile() tmp_out = tempfile.TemporaryFile() host.symbolize(tmp_in, tmp_out)
def test_zircon_tool(self): mock = MockHost() mock.zircon_tool(['mock_tool', 'mock_arg']) self.assertIn('mock/out/default.zircon/tools/mock_tool mock_arg', mock.history) # If a build tree is available, try using a zircon tool for "real". host = Host() try: host.set_build_dir(host.find_build_dir()) except Host.ConfigError: return with self.assertRaises(Host.ConfigError): host.zircon_tool(['no_such_tool']) path = os.path.abspath(__file__) line = host.zircon_tool(['merkleroot', path]) self.assertRegexpMatches(line, r'[0-9a-f]* - ' + path)
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)