Search in sources :

Example 6 with MockModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.

the class PostgreSQLNotificationParserTest method testLocalCodeNodeCommentParsingDelete.

@Test
public void testLocalCodeNodeCommentParsingDelete() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_code_nodes UPDATE 1 1111 4608 null");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processNodeLocalNodeCommentNotification(notification, provider);
    assertNotNull(result);
    final CodeNodeCommentNotificationContainer container = (CodeNodeCommentNotificationContainer) result;
    final INaviCodeNode node = container.getNode();
    assertEquals(1111, node.getId());
    assertEquals(new CAddress(4608), node.getAddress());
    assertEquals(CommentOperation.DELETE, container.getOperation());
    assertNull(container.getCommentId());
    assertEquals(CommentScope.LOCAL, container.getScope());
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) CodeNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CodeNodeCommentNotificationContainer) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 7 with MockModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.

the class TraceTest method testEvent.

@Test
public void testEvent() {
    final Trace trace = new Trace(new TraceList(1, "Name", "Description", new MockSqlProvider()));
    final MockTraceListener listener = new MockTraceListener();
    trace.addListener(listener);
    final MockModule module = new MockModule();
    final Module m = ModuleFactory.get(module);
    trace.addEvent(0, m, new Address(123), TraceEventType.Breakpoint);
    trace.addEvent(0, m, new Address(124), TraceEventType.EchoBreakpoint);
    assertEquals(2, trace.getEvents().size());
    assertEquals(123, trace.getEvents().get(0).getAddress().toLong());
    assertEquals(TraceEventType.Breakpoint, trace.getEvents().get(0).getType());
    assertEquals(124, trace.getEvents().get(1).getAddress().toLong());
    assertEquals(TraceEventType.EchoBreakpoint, trace.getEvents().get(1).getType());
    assertEquals("addedEvent;addedEvent;", listener.events);
    trace.removeListener(listener);
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) Test(org.junit.Test)

Example 8 with MockModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.

the class OperandTest method testConstructor.

@Test
public void testConstructor() {
    final MockModule mockModule = new MockModule();
    final COperandTreeNode rootNode = new COperandTreeNode(1, IOperandTree.NODE_TYPE_SIZE_PREFIX_ID, "b4", null, new ArrayList<IReference>(), new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
    final COperandTreeNode childNode = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
    COperandTreeNode.link(rootNode, childNode);
    final COperandTree tree = new COperandTree(rootNode, new MockSqlProvider(), mockModule.getTypeManager(), mockModule.getContent().getTypeInstanceContainer());
    final Operand operand = new Operand(tree);
    assertEquals("dword", operand.getRootNode().getValue());
    assertEquals(1, operand.getRootNode().getChildren().size());
    assertEquals("eax", operand.getRootNode().getChildren().get(0).getValue());
    assertEquals("eax", operand.toString());
}
Also used : MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) IReference(com.google.security.zynamics.zylib.disassembly.IReference) Test(org.junit.Test)

Example 9 with MockModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.

the class ProjectTest method testCreateAddressSpace.

@Test
public void testCreateAddressSpace() throws CouldntLoadDataException, CouldntSaveDataException {
    final MockProjectListener listener = new MockProjectListener();
    m_project.load();
    m_project.addListener(listener);
    final AddressSpace space = m_project.createAddressSpace("Hannes Space");
    space.load();
    final INaviModule nativeModule = new MockModule(provider);
    internalDatabase.getContent().addModule(nativeModule);
    final Module module = ModuleFactory.get(nativeModule, provider);
    module.load();
    space.addModule(module);
    assertEquals(space, m_project.getAddressSpaces().get(1));
    assertEquals("Hannes Space", m_internalProject.getContent().getAddressSpaces().get(1).getConfiguration().getName());
    assertEquals("addedAddressSpace;changedModificationDate;", listener.events);
    assertEquals(0, m_project.getFunctions().size());
    m_project.removeListener(listener);
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Test(org.junit.Test)

Example 10 with MockModule

use of com.google.security.zynamics.binnavi.disassembly.Modules.MockModule in project binnavi by google.

the class PostgreSQLNotificationParserTest method testTypeInstanceCommentParsingDeleteComment.

@Test
public void testTypeInstanceCommentParsingDeleteComment() throws CouldntSaveDataException, CouldntLoadDataException {
    final INaviModule module = new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    module.getContent().getSections().createSection("A", new CAddress(0), new CAddress(1234), SectionPermission.READ, null);
    final TypeInstance fakeInstance = module.getContent().getTypeInstanceContainer().createInstance("TYPE INSTANCE", null, module.getTypeManager().getTypes().get(0), module.getContent().getSections().getSection(0), 0);
    final PGNotification notification = new MockPGNotification("comment_changes", "bn_type_instances UPDATE 1 " + fakeInstance.getId() + " null");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processTypeInstanceCommentNotification(notification, provider);
    assertNotNull(result);
    final TypeInstanceCommentNotificationContainer container = (TypeInstanceCommentNotificationContainer) result;
    assertNotNull(container);
    final TypeInstance instance = container.getInstance();
    assertEquals(fakeInstance.getId(), instance.getId());
    assertEquals(CommentOperation.DELETE, container.getOperation());
    assertNull(container.getCommentId());
}
Also used : TypeInstanceCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TypeInstanceCommentNotificationContainer) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) PGNotification(org.postgresql.PGNotification) TypeInstance(com.google.security.zynamics.binnavi.disassembly.types.TypeInstance) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)98 Test (org.junit.Test)90 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)45 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)32 CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)26 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)24 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)14 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)14 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)13 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)13 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)12 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)12 CCodeBookmarkManager (com.google.security.zynamics.binnavi.models.Bookmarks.code.CCodeBookmarkManager)12 MockAddress (com.google.security.zynamics.zylib.disassembly.MockAddress)12 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)11 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)11 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)10 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)10 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)10 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)9