def test_state_loading(self): with tempfile.TemporaryDirectory() as tmpdir: # create a client only for accurate git usage client = binsync.Client("user0", tmpdir, "fake_hash", init_repo=True) state = binsync.State("user0", client=client) # create a state for dumping state.version = 1 func_header = binsync.data.FunctionHeader("some_name", 0x400080) state.set_function_header(func_header) # dump and commit state to tree client.commit_state(state) # load the state state_tree = client._get_tree(state.user, client.repo) new_state = binsync.State.parse(state_tree, client=client) self.assertEqual(new_state.user, "user0") self.assertEqual(new_state.version, 1) self.assertEqual(len(new_state.functions), 1) self.assertEqual(new_state.functions[0x400080].header, func_header)
def test_client_state(self): with tempfile.TemporaryDirectory() as tmpdir: client = binsync.Client("user0", tmpdir, "fake_hash", init_repo=True) state = client.get_state() self.assertEqual(state.user, "user0") # after create, state is dirty self.assertTrue(state.dirty) func_header = binsync.data.FunctionHeader("some_name", 0x400080) state.set_function_header(func_header) # it should be dirty still (more edits) self.assertTrue(state.dirty) # commit changes so we clean it! client.commit_state(state) self.assertFalse(state.dirty) state = client.get_state(user="******") self.assertTrue(len(state.functions), 1) self.assertTrue(state.functions[0x400080].header, func_header) # git is still running at least on windows client.close()
def test_client_creation(self): with tempfile.TemporaryDirectory() as tmpdir: client = binsync.Client("user0", tmpdir, "fake_hash", init_repo=True) self.assertTrue(os.path.isdir(os.path.join(tmpdir, ".git")))
def test_client_state(): # with tempfile.TemporaryDirectory() as tmpdir: tmpdir = tempfile.mkdtemp() client = binsync.Client("user0", tmpdir) state = client.get_state() nose.tools.assert_equal(state.user, "user0") func = binsync.data.Function(0x400080, name="some_name", notes="some comment!") # the state should be clean nose.tools.assert_false(state._dirty) state.set_function(func) # it should be dirty now nose.tools.assert_true(state._dirty) client.save_state() client.state = None state = client.get_state() nose.tools.assert_equal(len(state.functions), 1) nose.tools.assert_equal(state.functions[0x400080], func) client.close() # git is still running at least on windows
def connect(self, user, path, init_repo, ssh_agent_pid=None, ssh_auth_sock=None): self._client = binsync.Client(user, path, init_repo=init_repo, ssh_agent_pid=ssh_agent_pid, ssh_auth_sock=ssh_auth_sock) if self.control_panel is not None: self.control_panel.reload()
def test_state_dumping(self): with tempfile.TemporaryDirectory() as tmpdir: # create a client only for accurate git usage client = binsync.Client("user0", tmpdir, "fake_hash", init_repo=True) state = binsync.State("user0", client=client) # dump to the current repo, current branch state.dump(client.repo.index) metadata_path = os.path.join(tmpdir, "metadata.toml") self.assertTrue(os.path.isfile(metadata_path))
def connect(self, user, repo_path, init_repo=False, remote_url=None): if binsync is None: raise ImportError("binsync is not installed.") client = binsync.Client(user, repo_path, init_repo=init_repo, remote_url=remote_url) self.project.kb.sync.connect(client) # Spawn the worker thread thr = threading.Thread(target=self.worker_routine, daemon=True) thr.start()
def test_client_creation(): with tempfile.TemporaryDirectory() as tmpdir: client = binsync.Client("user0", tmpdir) nose.tools.assert_true(os.path.isdir(os.path.join(tmpdir, ".git")))