use of com.google.security.zynamics.zylib.types.lists.FilledList in project binnavi by google.
the class CPostgreSQLModuleContentTest method testCModuleContentConstructor.
@Test
public void testCModuleContentConstructor() throws LoadCancelledException, CouldntLoadDataException {
final CModule module = (CModule) getDatabase().getContent().getModules().get(0);
module.load();
final ListenerProvider<IModuleListener> listeners = new ListenerProvider<IModuleListener>();
final CCallgraph callgraph = module.getContent().getNativeCallgraph();
final IFilledList<INaviFunction> functions = new FilledList<INaviFunction>();
functions.add(module.getContent().getFunctionContainer().getFunctions().get(0));
final ICallgraphView nativeCallgraph = module.getContent().getViewContainer().getNativeCallgraphView();
final ImmutableList<IFlowgraphView> nativeFlowgraphs = module.getContent().getViewContainer().getNativeFlowgraphViews();
final List<INaviView> customViews = new ArrayList<INaviView>();
final ImmutableBiMap<INaviView, INaviFunction> viewFunctionMap = new ImmutableBiMap.Builder<INaviView, INaviFunction>().build();
new Pair<HashMap<INaviView, INaviFunction>, HashMap<INaviFunction, INaviView>>(null, null);
final IFilledList<TraceList> traces = new FilledList<TraceList>();
final SectionContainer sections = new SectionContainer(new SectionContainerBackend(getProvider(), module));
final TypeInstanceContainer instances = new TypeInstanceContainer(new TypeInstanceContainerBackend(getProvider(), module, module.getTypeManager(), sections), getProvider());
final CModuleContent moduleContent1 = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, traces, sections, instances);
assertNotNull(moduleContent1);
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(null, null, null, null, null, null, null, null, null, null, sections, instances);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, null, null, null, null, null, null, null, null, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), null, null, null, null, null, null, null, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, null, null, null, null, null, null, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, null, null, null, null, null, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, null, null, null, null, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, null, null, null, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, null, null, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, null, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, null, null, null);
fail();
} catch (final NullPointerException e) {
}
try {
@SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, traces, null, null);
fail();
} catch (final NullPointerException e) {
}
}
use of com.google.security.zynamics.zylib.types.lists.FilledList in project binnavi by google.
the class CTraceContainerTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException {
m_listener = new MockTraceContainerListener();
final CModule m_module = MockCreator.createModule(m_sql);
m_module.load();
m_content = new CTraceContainer(m_module, new FilledList<TraceList>(), m_sql);
m_content.addListener(m_listener);
}
use of com.google.security.zynamics.zylib.types.lists.FilledList in project binnavi by google.
the class CProjectContainerTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
m_provider = new MockSqlProvider();
m_module = new MockModule(m_provider);
m_database = new MockDatabase(m_provider);
m_function = new MockFunction(m_provider);
m_project = new CProject(123, "Name", "Comment", new Date(), new Date(), 55, new FilledList<DebuggerTemplate>(), m_provider);
m_project.load();
m_space = m_project.getContent().createAddressSpace("space");
m_space.load();
m_space.getContent().addModule(m_module);
m_debugger = new DebuggerTemplate(2, "gdb", "local", 2222, m_provider);
m_space.getConfiguration().setDebuggerTemplate(m_debugger);
m_listener = new MockAddressSpaceListener();
m_space.addListener(m_listener);
m_module.load();
CFunctionContainerHelper.addFunction(m_module.getContent().getFunctionContainer(), m_function);
final CView view = m_module.getContent().getViewContainer().createView("foo", "bar");
@SuppressWarnings("unused") final MockViewContainer mockViewContainer = new MockViewContainer();
final MockViewListener listener = new MockViewListener();
view.addListener(listener);
}
use of com.google.security.zynamics.zylib.types.lists.FilledList in project binnavi by google.
the class CUnInlinerTest method testOneBlock.
@Test
public void testOneBlock() {
final List<INaviViewNode> nodes = new FilledList<INaviViewNode>();
final List<INaviEdge> edges = new FilledList<INaviEdge>();
final INaviFunction mockFunction = new MockFunction();
final CCodeNode node = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
nodes.add(node);
final MockView view = new MockView(nodes, edges, m_provider);
CUnInliner.unInline(view, node);
}
use of com.google.security.zynamics.zylib.types.lists.FilledList in project binnavi by google.
the class CUnInlinerTest method testUninlineSingleBlockNested.
@Test
public void testUninlineSingleBlockNested() {
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(0x123);
final MockInstruction mi2 = new MockInstruction(0x124);
final MockInstruction mi3 = new MockInstruction(0x125);
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 childNode = new CCodeNode(5, 0, 0, 0, 0, Color.RED, Color.RED, false, true, null, mockFunction, new HashSet<CTag>(), m_provider);
upperNode.addInstruction(mi1, null);
inlinedNode.addInstruction(mi2, null);
lowerNode.addInstruction(mi3, null);
nodes.add(parentNode);
nodes.add(upperNode);
nodes.add(inlinedNode);
nodes.add(lowerNode);
nodes.add(childNode);
final CNaviViewEdge parentEdge = new CNaviViewEdge(0, parentNode, upperNode, EdgeType.ENTER_INLINED_FUNCTION, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge enteringEdge = new CNaviViewEdge(1, upperNode, inlinedNode, EdgeType.ENTER_INLINED_FUNCTION, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge leavingEdge = new CNaviViewEdge(2, inlinedNode, lowerNode, EdgeType.LEAVE_INLINED_FUNCTION, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
final CNaviViewEdge childEdge1 = new CNaviViewEdge(3, lowerNode, childNode, EdgeType.LEAVE_INLINED_FUNCTION, 0, 0, 0, 0, Color.BLACK, false, true, null, new FilledList<CBend>(), m_provider);
edges.add(parentEdge);
edges.add(enteringEdge);
edges.add(leavingEdge);
edges.add(childEdge1);
connect(parentNode, upperNode, parentEdge);
connect(upperNode, inlinedNode, enteringEdge);
connect(inlinedNode, lowerNode, leavingEdge);
connect(lowerNode, childNode, childEdge1);
final MockView view = new MockView(nodes, edges, m_provider);
CUnInliner.unInline(view, inlinedNode);
assertEquals(3, view.getNodeCount());
assertEquals(2, view.getEdgeCount());
assertEquals(EdgeType.ENTER_INLINED_FUNCTION, view.getGraph().getEdges().get(0).getType());
assertEquals(EdgeType.LEAVE_INLINED_FUNCTION, view.getGraph().getEdges().get(1).getType());
final INaviCodeNode cnode = (INaviCodeNode) view.getGraph().getNodes().get(2);
assertEquals(2, Iterables.size(cnode.getInstructions()));
assertEquals(mi1.toString(), Iterables.get(cnode.getInstructions(), 0).toString());
assertEquals(mi3.toString(), Iterables.get(cnode.getInstructions(), 1).toString());
}
Aggregations