use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex in project tracecompass by tracecompass.
the class TmfCriticalPathAlgorithmTest method testCriticalPath.
private void testCriticalPath(GraphBuilder builder, IGraphWorker obj) {
/* Get the base graph */
TmfGraph main = builder.build();
assertNotNull(main);
/* The expected critical path */
TmfGraph expected = getExpectedCriticalPath(builder);
assertNotNull(expected);
/* The actual critical path */
TmfVertex head = null;
if (obj == null) {
head = main.getHead();
} else {
head = main.getHead(obj);
}
assertNotNull(head);
TmfGraph actual = computeCriticalPath(main, head);
assertNotNull(actual);
/* Check the 2 graphs are equivalent */
GraphOps.checkEquality(expected, actual);
}
use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex in project tracecompass by tracecompass.
the class TmfGraphBuilderModuleTest method testBuildGraph.
/**
* Test the graph builder execution
*/
@Test
public void testBuildGraph() {
TmfXmlTraceStub trace = TmfXmlTraceStubNs.setupTrace(Activator.getAbsoluteFilePath(STUB_TRACE_FILE));
TmfGraphBuilderModule module = getModule(trace);
module.schedule();
module.waitForCompletion();
TmfGraph graph = module.getGraph();
assertNotNull(graph);
assertEquals(2, graph.getWorkers().size());
assertEquals(9, graph.size());
List<TmfVertex> vertices = graph.getNodesOf(new TestGraphWorker(1));
assertEquals(5, vertices.size());
long[] timestamps1 = { 1, 2, 5, 7, 12 };
boolean[][] hasEdges1 = { { false, true, false, false }, { true, false, false, true }, { false, true, true, false }, { true, false, false, false }, { false, false, true, false } };
for (int i = 0; i < vertices.size(); i++) {
TmfVertex v = vertices.get(i);
assertEquals(timestamps1[i], v.getTs());
assertEquals(hasEdges1[i][0], v.getEdge(EdgeDirection.INCOMING_HORIZONTAL_EDGE) != null);
assertEquals(hasEdges1[i][1], v.getEdge(EdgeDirection.OUTGOING_HORIZONTAL_EDGE) != null);
assertEquals(hasEdges1[i][2], v.getEdge(EdgeDirection.INCOMING_VERTICAL_EDGE) != null);
assertEquals(hasEdges1[i][3], v.getEdge(EdgeDirection.OUTGOING_VERTICAL_EDGE) != null);
}
vertices = graph.getNodesOf(new TestGraphWorker(2));
assertEquals(4, vertices.size());
long[] timestamps2 = { 2, 5, 10, 12 };
boolean[][] hasEdges2 = { { false, true, true, false }, { true, false, false, true }, { false, true, false, false }, { true, false, false, true } };
for (int i = 0; i < vertices.size(); i++) {
TmfVertex v = vertices.get(i);
assertEquals(timestamps2[i], v.getTs());
assertEquals(hasEdges2[i][0], v.getEdge(EdgeDirection.INCOMING_HORIZONTAL_EDGE) != null);
assertEquals(hasEdges2[i][1], v.getEdge(EdgeDirection.OUTGOING_HORIZONTAL_EDGE) != null);
assertEquals(hasEdges2[i][2], v.getEdge(EdgeDirection.INCOMING_VERTICAL_EDGE) != null);
assertEquals(hasEdges2[i][3], v.getEdge(EdgeDirection.OUTGOING_VERTICAL_EDGE) != null);
}
trace.dispose();
}
use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex in project tracecompass by tracecompass.
the class TmfGraphTest method testAddVertex.
/**
* Test the {@link TmfGraph#add(IGraphWorker, TmfVertex)} method: vertices are
* added, but no edge between them is created
*/
@Test
public void testAddVertex() {
fGraph.add(WORKER1, fV0);
fGraph.add(WORKER1, fV1);
List<TmfVertex> list = fGraph.getNodesOf(WORKER1);
assertEquals(2, list.size());
for (int i = 0; i < list.size() - 1; i++) {
TmfVertex vertex = list.get(i);
assertEquals(i, vertex.getTs());
assertNull(vertex.getEdge(EdgeDirection.OUTGOING_HORIZONTAL_EDGE));
assertNull(vertex.getEdge(EdgeDirection.INCOMING_HORIZONTAL_EDGE));
assertNull(vertex.getEdge(EdgeDirection.OUTGOING_VERTICAL_EDGE));
assertNull(vertex.getEdge(EdgeDirection.INCOMING_VERTICAL_EDGE));
}
}
use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex in project tracecompass by tracecompass.
the class TmfGraphTest method testCheckHorizontal.
/**
* Test the {@link TmfVertex#linkHorizontal(TmfVertex)} with non
* chronological timestamps
*/
@Test(expected = IllegalArgumentException.class)
public void testCheckHorizontal() {
TmfVertex n0 = new TmfVertex(10);
TmfVertex n1 = new TmfVertex(0);
n0.linkHorizontal(n1);
}
use of org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex in project tracecompass by tracecompass.
the class TmfGraphTest method testHorizontalSelfLink.
/**
* Test that exception is thrown if a node is linked horizontally to itself
*/
@Test(expected = IllegalArgumentException.class)
public void testHorizontalSelfLink() {
TmfVertex n0 = new TmfVertex(0);
n0.linkHorizontal(n0);
}
Aggregations