use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TmfTraceTest method testInitializeNullPath.
// ------------------------------------------------------------------------
// Trace initialization
// ------------------------------------------------------------------------
@Test
public void testInitializeNullPath() {
// Instantiate an "empty" trace
final TmfTraceStub trace = new TmfTraceStub();
try {
trace.initialize(null, null, ITmfEvent.class);
fail("TmfTrace.initialize() - no exception thrown");
} catch (TmfTraceException e) {
// Success
trace.dispose();
} catch (Exception e) {
fail("TmfTrace.initialize() - wrong exception thrown");
}
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class TraceValidateAndImportOperation method filterByTimerange.
private TraceFileSystemElement filterByTimerange(TraceFileSystemElement selectedFileSystemElements, IProgressMonitor monitor) {
SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
subMonitor.subTask(Messages.ImportTraceWizard_FilteringOperationTaskName);
String tracePath = selectedFileSystemElements.getFileSystemObject().getAbsolutePath();
ITmfTrace trace = null;
try {
TraceTypeHelper traceTypeHelper = TmfTraceTypeUIUtils.selectTraceType(tracePath, null, null);
if (traceTypeHelper == null) {
return null;
}
IConfigurationElement ce = TmfTraceType.getTraceAttributes(traceTypeHelper.getTraceTypeId());
if (ce == null) {
return null;
}
trace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);
ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);
trace.initTrace(null, tracePath, event.getClass());
if (isInTimerange(trace)) {
return selectedFileSystemElements;
}
} catch (TmfTraceImportException | CoreException | TmfTraceException e) {
// $NON-NLS-1$
String errorMessage = Messages.ImportTraceWizard_ImportProblem + ": " + tracePath;
Activator.getDefault().logError(errorMessage, e);
} finally {
if (trace != null) {
trace.dispose();
TmfTraceManager.deleteSupplementaryFolder(trace);
}
subMonitor.worked(1);
}
return null;
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class CpuUsageStateProviderTest 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 */
fModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, KernelCpuUsageAnalysis.class, KernelCpuUsageAnalysis.ID);
assertNotNull(fModule);
fTrace = trace;
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class LinuxTestCase method getKernelTrace.
/**
* Initializes the trace for this test case. This method will always create
* a new trace. The caller must dispose of it the proper way.
*
* @return The {@link TmfXmlKernelTraceStub} created for this test case
*/
public TmfXmlKernelTraceStub getKernelTrace() {
TmfXmlKernelTraceStub trace = new TmfXmlKernelTraceStub();
IPath filePath = Activator.getAbsoluteFilePath(fTraceFile);
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());
}
return trace;
}
use of org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException in project tracecompass by tracecompass.
the class CallStackTestData method getTrace.
/**
* Get the test trace
*
* @return The test trace, initialized
*/
public ITmfTrace getTrace() {
TmfXmlTraceStub trace = fTrace;
if (trace == null) {
trace = new TmfXmlTraceStubNs();
IPath filePath = ActivatorTest.getAbsoluteFilePath(getTraceFile());
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());
}
trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
fTrace = trace;
}
return trace;
}
Aggregations