Search in sources :

Example 16 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class ModuleFactory method get.

public static Module get(final INaviModule module) {
    final MockSqlProvider provider = new MockSqlProvider();
    final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
    final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
    final Database db = new Database(new MockDatabase());
    return new Module(db, module, nodeTagManager, viewTagManager);
}
Also used : TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule)

Example 17 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class ModuleHelpersTest method testGetFunction_2.

@Test
public void testGetFunction_2() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    final Database database = new Database(new MockDatabase());
    final MockModule mockModule = new MockModule();
    final MockSqlProvider provider = new MockSqlProvider();
    final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
    final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
    CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), parentFunction);
    final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    assertEquals(module.getFunctions().get(0), ModuleHelpers.getFunction(module, new Address(0x123)));
    assertNull(ModuleHelpers.getFunction(module, new Address(0x1235)));
    try {
        ModuleHelpers.getFunction(null, (Address) null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        ModuleHelpers.getFunction(module, (Address) null);
        fail();
    } catch (final NullPointerException e) {
    }
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Test(org.junit.Test)

Example 18 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class ModuleTest method testUnloaded.

@Test
public void testUnloaded() {
    m_module.close();
    try {
        m_module.getCallgraph();
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        final MockSqlProvider provider = new MockSqlProvider();
        final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
        final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
        m_module.getFunction(parentFunction);
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        m_module.getFunctions();
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        m_module.getViews();
        fail();
    } catch (final IllegalStateException exception) {
    }
    try {
        m_module.getTraces();
        fail();
    } catch (final IllegalStateException exception) {
    }
}
Also used : MockView(com.google.security.zynamics.binnavi.disassembly.MockView) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 19 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class TraceLoggerTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, InvalidDatabaseVersionException {
    final SQLProvider mockProvider = new MockSqlProvider();
    // CDatabase("", "", "", "", "", false,
    final IDatabase internalDatabase = new MockDatabase();
    // false);
    final Database database = new Database(internalDatabase);
    database.load();
    final MockProject mockProject = new MockProject();
    final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
    final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
    final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
    final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
    final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
    final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    final Project project = new Project(database, mockProject, nodeTagManager, viewTagManager);
    m_mockModule = new Module(database, mockModule, viewTagManager, nodeTagManager);
    m_debugSettings = new ModuleTargetSettings(m_mockModule.getNative());
    m_mockDebugger = new MockDebugger(m_debugSettings);
    m_mockDebugger.setAddressTranslator(mockModule, new CAddress(0), new CAddress(0x1000));
    final Debugger debugger = new Debugger(m_mockDebugger);
    m_logger = new TraceLogger(debugger, module);
    m_projectLogger = new TraceLogger(debugger, project);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) Project(com.google.security.zynamics.binnavi.API.disassembly.Project) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) Before(org.junit.Before)

Example 20 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class BasicBlockTest method testConstructor.

@Test
public void testConstructor() throws InternalTranslationException {
    final MockSqlProvider provider = new MockSqlProvider();
    final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
    final CFunction internalFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
    final List<INaviInstruction> instructions = new ArrayList<INaviInstruction>();
    instructions.add(new MockInstruction(0x123));
    final INaviBasicBlock bblock = new CBasicBlock(1, "Hannes", instructions);
    final IBlockNode node = new CBlockNode(bblock);
    final Function pFunction = new Function(ModuleFactory.get(), internalFunction);
    final BasicBlock block = new BasicBlock(node, pFunction);
    assertEquals(0x123, block.getAddress().toLong());
    assertEquals(pFunction, block.getParentFunction());
    assertEquals("Hannes", block.getComment());
    assertEquals(0x123, block.getInstructions().get(0).getAddress().toLong());
    assertNotNull(block.getReilCode());
    assertTrue(block.getChildren().isEmpty());
    assertTrue(block.getParents().isEmpty());
    assertEquals("123  nop \n", block.toString());
}
Also used : CBlockNode(com.google.security.zynamics.binnavi.disassembly.CBlockNode) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) IBlockNode(com.google.security.zynamics.binnavi.disassembly.IBlockNode) ArrayList(java.util.ArrayList) INaviBasicBlock(com.google.security.zynamics.binnavi.disassembly.INaviBasicBlock) CBasicBlock(com.google.security.zynamics.binnavi.disassembly.CBasicBlock) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) CBasicBlock(com.google.security.zynamics.binnavi.disassembly.CBasicBlock) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) MockInstruction(com.google.security.zynamics.binnavi.disassembly.MockInstruction) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) INaviBasicBlock(com.google.security.zynamics.binnavi.disassembly.INaviBasicBlock) Test(org.junit.Test)

Aggregations

MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)111 Test (org.junit.Test)82 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)55 Date (java.util.Date)47 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)44 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)42 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)32 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)29 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)25 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)24 Before (org.junit.Before)23 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)17 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)17 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)14 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)13 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)13 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)12 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)12 Tree (com.google.security.zynamics.zylib.types.trees.Tree)12 ArrayList (java.util.ArrayList)12