use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException 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.exceptions.TmfTraceException 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.exceptions.TmfTraceException 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.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class ExperimentBenchmark method init.
/**
* Initialization
*
* @param maxTraces
* maximum number of traces to open
*/
private void init(int maxTraces) {
try {
File parentDir = new File(TRACES_ROOT_PATH);
File[] traceFiles = parentDir.listFiles();
ITmfTrace[] traces = new CtfTmfTrace[Math.min(maxTraces, traceFiles.length)];
for (int i = 0; i < traces.length; i++) {
traces[i] = new CtfTmfTrace();
}
int j = 0;
for (int i = 0; i < (traces.length) && (j < traces.length); i++) {
String absolutePath = traceFiles[j].getAbsolutePath();
if (traces[i].validate(null, absolutePath).isOK()) {
traces[i].initTrace(null, absolutePath, ITmfEvent.class);
} else {
i--;
}
j++;
}
fExperiment = new TmfExperimentStub("MegaExperiment", traces, BLOCK_SIZE);
if (traces[traces.length - 1].getPath() == null) {
throw new TmfTraceException("Insufficient valid traces in directory");
}
} catch (TmfTraceException e) {
System.out.println(e.getMessage());
}
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class StatisticsAnalysisBenchmark method runTest.
private static void runTest(CtfTestTrace testTrace, String testName, Map<String, Long> testCases) {
Performance perf = Performance.getDefault();
PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName);
perf.tagAsSummary(pm, "Statistics Analysis: " + testName, Dimension.CPU_TIME);
if (testTrace == CtfTestTrace.DJANGO_CLIENT || testTrace == CtfTestTrace.DJANGO_HTTPD) {
/* Do not show all traces in the global summary */
perf.tagAsGlobalSummary(pm, "Statistics Analysis: " + testName, Dimension.CPU_TIME);
}
for (int i = 0; i < LOOP_COUNT; i++) {
LttngKernelTrace trace = null;
TmfStatisticsModule module = null;
try {
trace = new LttngKernelTrace();
module = new TmfStatisticsModule();
module.setId("test");
// TODO Allow the utility method to return a LttngKernelTrace directly
CtfTmfTrace ctfTmfTrace = CtfTmfTestTraceUtils.getTrace(testTrace);
trace.initTrace(null, ctfTmfTrace.getPath(), CtfTmfEvent.class);
module.setTrace(trace);
pm.start();
TmfTestHelper.executeAnalysis(module);
pm.stop();
ITmfStatistics stats = module.getStatistics();
if (stats == null) {
throw new IllegalStateException();
}
Map<String, Long> map = stats.getEventTypesTotal();
/*
* Test each of the entries
*/
try {
for (Entry<String, Long> entry : testCases.entrySet()) {
Long value = map.get(entry.getKey());
assertNotNull(value);
assertTrue(value.equals(entry.getValue()));
}
} catch (NullPointerException e) {
fail(e.getMessage());
}
/*
* Delete the supplementary files, so that the next iteration
* rebuilds the state system.
*/
File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(trace));
for (File file : suppDir.listFiles()) {
file.delete();
}
} catch (TmfAnalysisException | TmfTraceException e) {
fail(e.getMessage());
} finally {
if (module != null) {
module.dispose();
}
if (trace != null) {
trace.dispose();
}
}
}
pm.commit();
CtfTmfTestTraceUtils.dispose(testTrace);
}
Aggregations