use of com.google.security.zynamics.binnavi.disassembly.INaviEdge in project binnavi by google.
the class CUnInlinerTest method testUninlineSingleBlockLoop.
@Test
public void testUninlineSingleBlockLoop() {
final List<INaviViewNode> nodes = new FilledList<INaviViewNode>();
final List<INaviEdge> edges = new FilledList<INaviEdge>();
final INaviFunction mockFunction = new MockFunction(m_provider);
final INaviFunction mockFunction2 = new MockFunction(m_provider);
final MockInstruction mi1 = new MockInstruction(0x111);
final MockInstruction mi2 = new MockInstruction(0x222);
final MockInstruction mi3 = new MockInstruction(0x333);
final MockInstruction mi4 = new MockInstruction(0x444);
final MockInstruction mi5 = new MockInstruction(0x555);
final MockInstruction mi6 = new MockInstruction(0x666);
final CCodeNode parentNode = new CCodeNode(1, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
final CCodeNode upperNode = new CCodeNode(2, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
final CCodeNode inlinedNode = new CCodeNode(3, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction2, new HashSet<CTag>(), m_provider);
final CCodeNode lowerNode = new CCodeNode(4, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
final CCodeNode childNode1 = new CCodeNode(5, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
final CCodeNode childNode2 = new CCodeNode(6, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
parentNode.addInstruction(mi1, null);
upperNode.addInstruction(mi2, null);
inlinedNode.addInstruction(mi3, null);
lowerNode.addInstruction(mi4, null);
childNode1.addInstruction(mi5, null);
childNode2.addInstruction(mi6, null);
nodes.add(parentNode);
nodes.add(upperNode);
nodes.add(inlinedNode);
nodes.add(lowerNode);
nodes.add(childNode1);
nodes.add(childNode2);
final CNaviViewEdge parentUpperEdge = new CNaviViewEdge(1, parentNode, upperNode, EdgeType.JUMP_UNCONDITIONAL, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge upperInlinedEdge = new CNaviViewEdge(2, upperNode, inlinedNode, EdgeType.ENTER_INLINED_FUNCTION, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge inlingedLowerEdge = new CNaviViewEdge(3, inlinedNode, lowerNode, EdgeType.LEAVE_INLINED_FUNCTION, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge lowerChild1Edge = new CNaviViewEdge(4, lowerNode, childNode1, EdgeType.JUMP_CONDITIONAL_TRUE, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge lowerChild2Edge = new CNaviViewEdge(5, lowerNode, childNode2, EdgeType.JUMP_CONDITIONAL_FALSE, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge child1UpperEdge = new CNaviViewEdge(6, childNode1, upperNode, EdgeType.JUMP_UNCONDITIONAL_LOOP, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
edges.add(parentUpperEdge);
edges.add(upperInlinedEdge);
edges.add(inlingedLowerEdge);
edges.add(lowerChild1Edge);
edges.add(lowerChild2Edge);
edges.add(child1UpperEdge);
connect(parentNode, upperNode, parentUpperEdge);
connect(upperNode, inlinedNode, upperInlinedEdge);
connect(inlinedNode, lowerNode, inlingedLowerEdge);
connect(lowerNode, childNode1, lowerChild1Edge);
connect(lowerNode, childNode2, lowerChild2Edge);
connect(childNode1, upperNode, child1UpperEdge);
final MockView view = new MockView(nodes, edges, m_provider);
CUnInliner.unInline(view, inlinedNode);
assertEquals(4, view.getNodeCount());
assertEquals(4, view.getEdgeCount());
assertEquals(EdgeType.JUMP_UNCONDITIONAL, view.getGraph().getEdges().get(0).getType());
assertEquals(EdgeType.JUMP_UNCONDITIONAL_LOOP, view.getGraph().getEdges().get(1).getType());
assertEquals(EdgeType.JUMP_CONDITIONAL_TRUE, view.getGraph().getEdges().get(2).getType());
assertEquals(EdgeType.JUMP_CONDITIONAL_FALSE, view.getGraph().getEdges().get(3).getType());
final INaviCodeNode cnode = (INaviCodeNode) view.getGraph().getNodes().get(3);
assertEquals(2, Iterables.size(cnode.getInstructions()));
assertEquals(mi2.toString(), Iterables.get(cnode.getInstructions(), 0).toString());
assertEquals(mi4.toString(), Iterables.get(cnode.getInstructions(), 1).toString());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviEdge in project binnavi by google.
the class PostgreSQLNotificationProviderTest method testDeleteGlobalEdgeCommentSync.
@Test
public void testDeleteGlobalEdgeCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, InterruptedException, CouldntDeleteException {
final INaviEdge databaseOneEdge = databaseOneView.getContent().getGraph().getEdges().get(3);
final INaviEdge databaseTwoEdge = databaseTwoView.getContent().getGraph().getEdges().get(3);
final List<IComment> oneBefore = databaseOneEdge.getGlobalComment() == null ? new ArrayList<IComment>() : databaseOneEdge.getGlobalComment();
final List<IComment> twoBefore = databaseTwoEdge.getGlobalComment() == null ? new ArrayList<IComment>() : databaseTwoEdge.getGlobalComment();
assertEquals(oneBefore, twoBefore);
databaseOneEdge.appendGlobalComment(" TEST NOTIFICATION PROVIDER TESTS (GLOBAL CODE NODE COMMENT) ");
// database one to two over the PostgreSQL back end.
synchronized (lock) {
lock.await(1000, TimeUnit.MILLISECONDS);
}
final List<IComment> oneAfter = databaseOneEdge.getGlobalComment();
final List<IComment> twoAfter = databaseTwoEdge.getGlobalComment();
assertNotNull(oneAfter);
assertNotNull(twoAfter);
assertEquals(oneBefore.size() + 1, oneAfter.size());
assertEquals(twoBefore.size() + 1, twoAfter.size());
assertEquals(oneAfter, twoAfter);
final int oneTwoSize = oneAfter.size();
final int twoTwoSize = twoAfter.size();
databaseOneEdge.deleteGlobalComment(Iterables.getLast(databaseOneEdge.getGlobalComment()));
// database one to two over the PostgreSQL back end.
synchronized (lock) {
lock.await(1000, TimeUnit.MILLISECONDS);
}
final List<IComment> oneThree = databaseOneEdge.getGlobalComment();
final List<IComment> twoThree = databaseTwoEdge.getGlobalComment();
assertEquals(oneTwoSize - 1, oneThree.size());
assertEquals(twoTwoSize - 1, twoThree.size());
assertEquals(oneThree, twoThree);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviEdge in project binnavi by google.
the class PostgreSQLNotificationProviderTest method testEditGlobalEdgeCommentSync.
@Test
public void testEditGlobalEdgeCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, InterruptedException {
final INaviEdge databaseOneEdge = databaseOneView.getContent().getGraph().getEdges().get(3);
final INaviEdge databaseTwoEdge = databaseTwoView.getContent().getGraph().getEdges().get(3);
final List<IComment> oneBefore = databaseOneEdge.getGlobalComment() == null ? new ArrayList<IComment>() : databaseOneEdge.getGlobalComment();
final List<IComment> twoBefore = databaseTwoEdge.getGlobalComment() == null ? new ArrayList<IComment>() : databaseTwoEdge.getGlobalComment();
assertEquals(oneBefore, twoBefore);
databaseOneEdge.appendGlobalComment(" TEST NOTIFICATION PROVIDER TESTS (GLOBAL EDGE COMMENT) BEFORE ");
// database one to two over the PostgreSQL back end.
synchronized (lock) {
lock.await(1000, TimeUnit.MILLISECONDS);
}
final List<IComment> oneAfter = databaseOneEdge.getGlobalComment();
final List<IComment> twoAfter = databaseTwoEdge.getGlobalComment();
assertNotNull(oneAfter);
assertNotNull(twoAfter);
assertEquals(oneBefore.size() + 1, oneAfter.size());
assertEquals(twoBefore.size() + 1, twoAfter.size());
assertEquals(oneAfter, twoAfter);
final int oneTwoSize = oneAfter.size();
final int twoTwoSize = twoAfter.size();
databaseOneEdge.editGlobalComment(Iterables.getLast(databaseOneEdge.getGlobalComment()), " TEST NOTIFICATION PROVIDER TESTS (GLOBAL EDGE COMMENT) AFTER ");
// database one to two over the PostgreSQL back end.
synchronized (lock) {
lock.await(1000, TimeUnit.MILLISECONDS);
}
final List<IComment> oneThree = databaseOneEdge.getGlobalComment();
final List<IComment> twoThree = databaseTwoEdge.getGlobalComment();
assertEquals(oneTwoSize, oneThree.size());
assertEquals(twoTwoSize, twoThree.size());
assertEquals(oneThree, twoThree);
assertEquals(" TEST NOTIFICATION PROVIDER TESTS (GLOBAL EDGE COMMENT) AFTER ", Iterables.getLast(oneThree).getComment());
assertEquals(" TEST NOTIFICATION PROVIDER TESTS (GLOBAL EDGE COMMENT) AFTER ", Iterables.getLast(twoThree).getComment());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviEdge in project binnavi by google.
the class PostgreSQLNotificationProviderTest method testAppendGlobalEdgeCommentSync.
@Test
public void testAppendGlobalEdgeCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, InterruptedException {
final INaviEdge databaseOneEdge = databaseOneView.getContent().getGraph().getEdges().get(3);
final INaviEdge databaseTwoEdge = databaseTwoView.getContent().getGraph().getEdges().get(3);
final List<IComment> oneBefore = databaseOneEdge.getGlobalComment() == null ? new ArrayList<IComment>() : databaseOneEdge.getGlobalComment();
final List<IComment> twoBefore = databaseTwoEdge.getGlobalComment() == null ? new ArrayList<IComment>() : databaseTwoEdge.getGlobalComment();
assertEquals(oneBefore, twoBefore);
databaseOneEdge.appendGlobalComment(" TEST NOTIFICATION PROVIDER TESTS (GLOBAL CODE NODE COMMENT) ");
// database one to two over the PostgreSQL back end.
synchronized (lock) {
lock.await(1000, TimeUnit.MILLISECONDS);
}
final List<IComment> oneAfter = databaseOneEdge.getGlobalComment();
final List<IComment> twoAfter = databaseTwoEdge.getGlobalComment();
assertNotNull(oneAfter);
assertNotNull(twoAfter);
assertEquals(oneBefore.size() + 1, oneAfter.size());
assertEquals(twoBefore.size() + 1, twoAfter.size());
assertEquals(oneAfter, twoAfter);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviEdge in project binnavi by google.
the class PostgreSQLNotificationProviderTest method testEditLocalEdgeCommentSync.
@Test
public void testEditLocalEdgeCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, InterruptedException {
final INaviEdge databaseOneEdge = databaseOneView.getContent().getGraph().getEdges().get(3);
final INaviEdge databaseTwoEdge = databaseTwoView.getContent().getGraph().getEdges().get(3);
final List<IComment> oneBefore = databaseOneEdge.getLocalComment() == null ? new ArrayList<IComment>() : databaseOneEdge.getLocalComment();
final List<IComment> twoBefore = databaseTwoEdge.getLocalComment() == null ? new ArrayList<IComment>() : databaseTwoEdge.getLocalComment();
assertEquals(oneBefore, twoBefore);
final List<IComment> comments = databaseOneEdge.appendLocalComment(" TEST NOTIFICATION PROVIDER TESTS (LOCAL EDGE COMMENT) BEFORE ");
// database one to two over the PostgreSQL back end.
synchronized (lock) {
lock.await(1000, TimeUnit.MILLISECONDS);
}
final List<IComment> oneAfter = databaseOneEdge.getLocalComment();
final List<IComment> twoAfter = databaseTwoEdge.getLocalComment();
assertNotNull(oneAfter);
assertNotNull(twoAfter);
assertEquals(oneBefore.size() + 1, oneAfter.size());
assertEquals(twoBefore.size() + 1, twoAfter.size());
assertEquals(oneAfter, twoAfter);
final int oneTwoSize = oneAfter.size();
final int twoTwoSize = twoAfter.size();
databaseOneEdge.editLocalComment(Iterables.getLast(comments), " TEST NOTIFICATION PROVIDER TESTS (LOCAL EDGE COMMENT) AFTER ");
// database one to two over the PostgreSQL back end.
synchronized (lock) {
lock.await(1000, TimeUnit.MILLISECONDS);
}
final List<IComment> oneThree = databaseOneEdge.getLocalComment();
final List<IComment> twoThree = databaseTwoEdge.getLocalComment();
assertEquals(oneTwoSize, oneThree.size());
assertEquals(twoTwoSize, twoThree.size());
assertEquals(oneThree, twoThree);
assertEquals(" TEST NOTIFICATION PROVIDER TESTS (LOCAL EDGE COMMENT) AFTER ", Iterables.getLast(oneThree).getComment());
assertEquals(" TEST NOTIFICATION PROVIDER TESTS (LOCAL EDGE COMMENT) AFTER ", Iterables.getLast(twoThree).getComment());
}
Aggregations