Search in sources :

Example 71 with MockModule

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

the class PostgreSQLNotificationParserTest method testGlobalInstructionCommentParsingAppend.

@Test
public void testGlobalInstructionCommentParsingAppend() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_instructions UPDATE 1 4608 3333");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processInstructionGlobalCommentNotification(notification, provider);
    assertNotNull(result);
    final InstructionCommentNotificationContainer container = (InstructionCommentNotificationContainer) result;
    final INaviInstruction instruction = container.getInstruction();
    assertEquals(new CAddress(4608), instruction.getAddress());
    assertEquals(CommentOperation.APPEND, container.getOperation());
    assertEquals(new Integer(3333), container.getCommentId());
    assertEquals(CommentScope.GLOBAL, container.getScope());
}
Also used : CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) InstructionCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.InstructionCommentNotificationContainer) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 72 with MockModule

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

the class PostgreSQLNotificationParserTest method testFunctionNodeCommentParsingAppendCommentUnknownModule.

@Test
public void testFunctionNodeCommentParsingAppendCommentUnknownModule() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 2 6666 4608 3333");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionNodeCommentNotification(notification, provider);
    assertNull(result);
}
Also used : CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Test(org.junit.Test)

Example 73 with MockModule

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

the class PostgreSQLNotificationParserTest method testGlobalEdgeCommentParsingDeleteLastComment.

@Test
public void testGlobalEdgeCommentParsingDeleteLastComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_global_edge_comments DELETE 1 1 4608 4614");
    Collection<CommentNotification> result = PostgreSQLCommentNotificationParser.processEdgeGlobalCommentNotification(notification, provider);
    assertEquals(1, result.size());
    final EdgeCommentNotificationContainer container = (EdgeCommentNotificationContainer) Iterables.getFirst(result, null);
    final INaviEdge edge = container.getEdge();
    assertEquals(1111, edge.getId());
    assertEquals(CommentOperation.DELETE, container.getOperation());
    assertNull(container.getCommentId());
    assertEquals(CommentScope.GLOBAL, container.getScope());
}
Also used : EdgeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) Test(org.junit.Test)

Example 74 with MockModule

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

the class PostgreSQLNotificationParserTest method testFunctionNodeCommentParsingAppendComment.

@Test
public void testFunctionNodeCommentParsingAppendComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 1 6666 4608 3333");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionNodeCommentNotification(notification, provider);
    assertNotNull(result);
    final FunctionNodeCommentNotificationContainer container = (FunctionNodeCommentNotificationContainer) result;
    final INaviFunction function = container.getNode().getFunction();
    assertEquals(new CAddress(4608), function.getAddress());
    assertEquals(CommentOperation.APPEND, container.getOperation());
    assertEquals(new Integer(3333), container.getCommentId());
}
Also used : CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) FunctionNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNodeCommentNotificationContainer) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 75 with MockModule

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

the class PostgreSQLNotificationParserTest method testFunctionNodeCommentParsingCompleteGarbageInput.

@Test
public void testFunctionNodeCommentParsingCompleteGarbageInput() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    // Normal input "bn_function_nodes UPDATE 1 6666 4608 null"
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes 1 1 1 1 1"));
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes UPDATE"));
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 1 "));
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes"));
    notifications.add(new MockPGNotification("comment_changes", "bn_function_nodes 1 FOO FOO FOOO ooqwkepqwpoekpqowkep" + "oqw\\n\\\n\\\n\\\\\\n\\n\n\\n\\\n\\n\\\n\\c\\c\\c\\c" + "ckepokqwpekpqwokepoaksjeofijsoiefjosejfosjoefjsoisje" + "foisjefoisjeofijsoeifjsoeifj"));
    for (PGNotification notification : notifications) {
        assertNull(PostgreSQLCommentNotificationParser.processFunctionCommentNotification(notification, provider));
    }
}
Also used : MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) PGNotification(org.postgresql.PGNotification) 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