use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.
the class ContextSwitchProviderTest method setUp.
/**
* Setup the trace for the tests
*/
@Before
public void setUp() {
ITmfTrace trace = new TmfXmlKernelTraceStub();
IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE);
IStatus status = trace.validate(null, filePath.toOSString());
if (!status.isOK()) {
fail(status.getException().getMessage());
}
try {
trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
} catch (TmfTraceException e) {
fail(e.getMessage());
}
deleteSuppFiles(trace);
((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelContextSwitchAnalysis.class, KernelContextSwitchAnalysis.ID);
assertNotNull(fModule);
fTrace = trace;
}
use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.
the class CpuUsageDataProviderTest method setUp.
/**
* Setup the trace for the tests
*/
@Before
public void setUp() {
IKernelTrace trace = new TmfXmlKernelTraceStub();
IPath filePath = Activator.getAbsoluteFilePath(CPU_USAGE_FILE);
IStatus status = trace.validate(null, filePath.toOSString());
if (!status.isOK()) {
fail(status.getException().getMessage());
}
try {
trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
} catch (TmfTraceException e) {
fail(e.getMessage());
}
deleteSuppFiles(trace);
((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
/*
* FIXME: Make sure this analysis is finished before running the CPU analysis.
* This block can be removed once analysis dependency and request precedence is
* implemented
*/
IAnalysisModule module = null;
for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TidAnalysisModule.class)) {
module = mod;
}
assertNotNull(module);
module.schedule();
module.waitForCompletion();
/* End of the FIXME block */
module = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID);
assertNotNull(module);
module.schedule();
module.waitForCompletion();
fDataProvider = CpuUsageDataProvider.create(trace);
assertNotNull(fDataProvider);
fTrace = trace;
}
use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.
the class AbstractTestInputOutput method setUp.
/**
* Setup the trace for the tests and return the InputOutputAnalysisModule,
* not executed.
*
* @param fileName
* The file name of the trace to open
* @return The input output analysis module
*/
@NonNull
protected InputOutputAnalysisModule setUp(String fileName) {
TmfXmlKernelTraceStub trace = new TmfXmlKernelTraceStub();
trace.addEventAspect(KernelTidAspect.INSTANCE);
trace.setKernelEventLayout(EVENT_LAYOUT);
IPath filePath = Activator.getAbsoluteFilePath(IO_FILE_PATH + fileName);
IStatus status = trace.validate(null, filePath.toOSString());
if (!status.isOK()) {
fail(status.getException().getMessage());
}
try {
trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
} catch (TmfTraceException e) {
fail(e.getMessage());
}
deleteSuppFiles(trace);
((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
fTrace = trace;
/* Start the kernel analysis module */
KernelAnalysisModule kernelMod = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelAnalysisModule.class, KernelAnalysisModule.ID);
assertNotNull(kernelMod);
kernelMod.schedule();
kernelMod.waitForCompletion();
InputOutputAnalysisModule module = TmfTraceUtils.getAnalysisModuleOfClass(trace, InputOutputAnalysisModule.class, InputOutputAnalysisModule.ID);
assertNotNull(module);
return module;
}
use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.
the class XmlDataProviderManagerTest method testOneTrace.
/**
* Test getting the XML data provider for one trace, with an analysis that
* applies to a trace
*/
@Test
public void testOneTrace() {
ITmfTrace trace = null;
try {
// Initialize the trace and module
trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
((TmfTrace) trace).traceOpened(signal);
// The data provider manager uses opened traces from the manager
TmfTraceManager.getInstance().traceOpened(signal);
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
assertNotNull(viewElement);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
assertNotNull(timeGraphProvider);
} finally {
if (trace != null) {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
}
use of org.eclipse.tracecompass.tmf.core.trace.TmfTrace in project tracecompass by tracecompass.
the class XmlDataProviderManagerTest method testExperimentWithTraceAnalysis.
/**
* Test getting the XML data provider for an experiment, with an analysis that
* applies to a trace
*/
@Test
public void testExperimentWithTraceAnalysis() {
ITmfTrace trace = null;
ITmfTrace trace2 = null;
ITmfTrace experiment = null;
try {
// Initialize the trace and module
trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
trace2 = XmlUtilsTest.initializeTrace(TEST_TRACE2);
ITmfTrace[] traces = { trace, trace2 };
experiment = new TmfExperiment(ITmfEvent.class, "Xml Experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, experiment, null);
((TmfTrace) trace).traceOpened(signal);
((TmfTrace) trace2).traceOpened(signal);
((TmfTrace) experiment).traceOpened(signal);
// The data provider manager uses opened traces from the manager
TmfTraceManager.getInstance().traceOpened(signal);
Iterable<@NonNull DataDrivenAnalysisModule> modules = TmfTraceUtils.getAnalysisModulesOfClass(experiment, DataDrivenAnalysisModule.class);
modules.forEach(module -> {
module.schedule();
assertTrue(module.waitForCompletion());
});
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
assertNotNull(viewElement);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(experiment, viewElement);
assertNotNull(timeGraphProvider);
assertTrue(timeGraphProvider instanceof TmfTimeGraphCompositeDataProvider);
} finally {
if (trace != null) {
trace.dispose();
}
if (trace2 != null) {
trace2.dispose();
}
if (experiment != null) {
experiment.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, experiment));
}
}
}
Aggregations