예제 #1
0
파일: test_state.py 프로젝트: angr/binsync
    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)
예제 #2
0
    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()
예제 #3
0
 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")))
예제 #4
0
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
예제 #5
0
 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()
예제 #6
0
파일: test_state.py 프로젝트: angr/binsync
    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))
예제 #7
0
    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()
예제 #8
0
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")))