import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.AggregatedCalledFunction;
import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.CallGraphAnalysis;
+import org.eclipse.tracecompass.internal.analysis.timing.core.callgraph.ThreadNode;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.StateSystemFactory;
return fixture;
}
+ private CGAnalysis fCga;
+
/**
* Test an empty state system.
*/
fixture.closeHistory(1002);
CGAnalysis cga = new CGAnalysis();
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
assertNotNull(threads);
assertEquals("Number of threads found", 0, threads.size());
}
// Build the state system
long start = 1;
long end = 1001;
- int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+ int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH);
+ int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+ fixture.updateOngoingState(TmfStateValue.newValueLong(100), threadQuark);
for (int i = 1; i <= SMALL_AMOUNT_OF_SEGMENT; i++) {
int quark = fixture.getQuarkRelativeAndAdd(parentQuark, Integer.toString(i));
TmfStateValue statev = TmfStateValue.newValueLong(i);
fixture.closeHistory(1002);
// Execute the CallGraphAnalysis
CGAnalysis cga = new CGAnalysis();
+ setCga(cga);
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
@NonNull
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
+ assertEquals("Thread id", 100, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
assertEquals("Children number: First function", 1, firstFunction.getChildren().size());
public void treeTest() {
ITmfStateSystemBuilder fixture = createFixture();
// Build the state system
- int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+ int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH);
+ int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+ fixture.updateOngoingState(TmfStateValue.newValueDouble(0.001), threadQuark);
int quark = fixture.getQuarkRelativeAndAdd(parentQuark, QUARK_0);
TmfStateValue statev = TmfStateValue.newValueLong(0);
fixture.modifyAttribute(0, statev, quark);
// Execute the CallGraphAnalysis
CGAnalysis cga = new CGAnalysis();
+ setCga(cga);
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- @NonNull
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
assertEquals("Children number: First function", 1, firstFunction.getChildren().size());
public void mergeFirstLevelCalleesTest() {
ITmfStateSystemBuilder fixture = createFixture();
// Build the state system
- int parentQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, THREAD_PATH, CALLSTACK_PATH);
+ int threadQuark = fixture.getQuarkAbsoluteAndAdd(PROCESS_PATH, "123");
+ int parentQuark = fixture.getQuarkRelativeAndAdd(threadQuark, CALLSTACK_PATH);
+ fixture.updateOngoingState(TmfStateValue.newValueDouble(0.001), threadQuark);
int quark = fixture.getQuarkRelativeAndAdd(parentQuark, QUARK_0);
TmfStateValue statev = TmfStateValue.newValueLong(0);
fixture.modifyAttribute(0, statev, quark);
// Execute the CallGraphAnalysis
CGAnalysis cga = new CGAnalysis();
- assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ String @NonNull [] tp = { "123" };
+ assertTrue(cga.iterateOverStateSystem(fixture, tp, PP, CSP, new NullProgressMonitor()));
+ setCga(cga);
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", 123, threads.get(0).getId());
+ assertEquals("Thread name", "123", threads.get(0).getSymbol());
assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
Object[] children = threads.get(0).getChildren().toArray();
buildCallStack(fixture);
// Execute the CallGraphAnalysis
CGAnalysis cga = new CGAnalysis();
+ setCga(cga);
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction main = (AggregatedCalledFunction) children[0];
fixture.closeHistory(11);
// Execute the callGraphAnalysis
CGAnalysis cga = new CGAnalysis();
+ setCga(cga);
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction parent = (AggregatedCalledFunction) children[0];
for (int i = 1; i < LARGE_AMOUNT_OF_SEGMENTS; i++) {
// Execute the callGraphAnalysis
CGAnalysis cga = new CGAnalysis();
+ setCga(cga);
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
assertEquals("Number of root functions ", 1, threads.get(0).getChildren().size());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
// Execute the callGraphAnalysis
CGAnalysis cga = new CGAnalysis();
+ setCga(cga);
assertTrue(cga.iterateOverStateSystem(fixture, TP, PP, CSP, new NullProgressMonitor()));
- List<AggregatedCalledFunction> threads = cga.getThreadNodes();
+ List<ThreadNode> threads = cga.getThreadNodes();
// Test the threads generated by the analysis
assertNotNull(threads);
assertEquals("Number of thread nodes Found", 1, threads.size());
+ assertEquals("Thread id", -1, threads.get(0).getId());
+ assertEquals("Thread name", "Thread", threads.get(0).getSymbol());
assertEquals("Number of root functions ", 2, threads.get(0).getChildren().size());
Object[] children = threads.get(0).getChildren().toArray();
AggregatedCalledFunction firstFunction = (AggregatedCalledFunction) children[0];
assertEquals("Test third function's number of calls", 1, function4.getNbCalls());
}
+
+ /**
+ * Gets the call graph analysis
+ * @return the call graph analysis
+ */
+ protected CGAnalysis getCga() {
+ return fCga;
+ }
+
+ private void setCga(CGAnalysis cga) {
+ fCga = cga;
+ }
}