Search in sources :

Example 46 with TmfTraceException

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");
    }
}
Also used : TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) Test(org.junit.Test)

Example 47 with TmfTraceException

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;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TraceTypeHelper(org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper) TmfTraceImportException(org.eclipse.tracecompass.tmf.core.project.model.TmfTraceImportException) CoreException(org.eclipse.core.runtime.CoreException) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) SubMonitor(org.eclipse.core.runtime.SubMonitor) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 48 with TmfTraceException

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TmfXmlKernelTraceStub(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub) IPath(org.eclipse.core.runtime.IPath) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) KernelCpuUsageAnalysis(org.eclipse.tracecompass.analysis.os.linux.core.cpuusage.KernelCpuUsageAnalysis) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) IKernelTrace(org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace) Before(org.junit.Before)

Example 49 with TmfTraceException

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) TmfXmlKernelTraceStub(org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub) IPath(org.eclipse.core.runtime.IPath) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)

Example 50 with TmfTraceException

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;
}
Also used : TmfXmlTraceStubNs(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) TmfXmlTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)

Aggregations

TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)50 File (java.io.File)17 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)14 IStatus (org.eclipse.core.runtime.IStatus)12 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)12 TmfTraceStub (org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub)11 IOException (java.io.IOException)10 IPath (org.eclipse.core.runtime.IPath)8 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)8 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)8 TmfXmlKernelTraceStub (org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub)7 Performance (org.eclipse.test.performance.Performance)6 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)6 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)6 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)6 Before (org.junit.Before)6 LttngKernelTrace (org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4