Search in sources :

Example 11 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class AbstractProviderTest method setUp.

// ------------------------------------------------------------------------
// Maintenance
// ------------------------------------------------------------------------
/**
 * Perform pre-class initialization.
 */
@Before
public void setUp() {
    CtfTestTrace testTrace = getTestTrace();
    LttngUstTrace trace = LttngUstTestTraceUtils.getTrace(testTrace);
    fTrace = trace;
    fModule = new TestLttngCallStackModule();
    try {
        assertTrue(fModule.setTrace(trace));
    } catch (TmfAnalysisException e) {
        fail();
    }
    fModule.schedule();
    assertTrue(fModule.waitForCompletion());
    fSS = fModule.getStateSystem();
    assertNotNull(fSS);
}
Also used : LttngUstTrace(org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) Before(org.junit.Before)

Example 12 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class AbstractProviderTest method testOtherUstTrace.

// ------------------------------------------------------------------------
// Test methods
// ------------------------------------------------------------------------
/**
 * Test the handling of generic UST traces who do not contain the required
 * information.
 */
@Test
public void testOtherUstTrace() {
    /* Initialize the trace and analysis module */
    File suppDir;
    CtfTmfTrace ustTrace = CtfTmfTestTraceUtils.getTrace(otherUstTrace);
    TestLttngCallStackModule module = null;
    try {
        module = new TestLttngCallStackModule();
        try {
            assertTrue(module.setTrace(ustTrace));
        } catch (TmfAnalysisException e) {
            fail();
        }
        module.schedule();
        assertTrue(module.waitForCompletion());
        /* Make sure the generated state system exists, but is empty */
        ITmfStateSystem ss = module.getStateSystem();
        assertNotNull(ss);
        assertTrue(ss.getStartTime() >= ustTrace.getStartTime().toNanos());
        assertEquals(0, ss.getNbAttributes());
    } finally {
        if (module != null) {
            module.dispose();
        }
    }
    suppDir = new File(TmfTraceManager.getSupplementaryFileDir(ustTrace));
    ustTrace.dispose();
    deleteDirectory(suppDir);
    assertFalse(suppDir.exists());
}
Also used : TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) File(java.io.File) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Example 13 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class TmfXmlConditionTest method testConditionsValidation.

/**
 * Test basic conditions on a state provider analysis
 */
@Test
public void testConditionsValidation() {
    ITmfTrace trace = XmlUtilsTest.initializeTrace(testTrace2);
    DataDrivenAnalysisModule module = XmlUtilsTest.initializeModule(TmfXmlTestFiles.CONDITION_FILE);
    try {
        module.setTrace(trace);
        module.schedule();
        module.waitForCompletion();
        ITmfStateSystem ss = module.getStateSystem();
        assertNotNull(ss);
        List<Integer> quarks = ss.getQuarks("*");
        assertEquals(5, quarks.size());
        for (Integer quark : quarks) {
            String name = ss.getAttributeName(quark);
            switch(name) {
                case "test":
                    {
                        final int[] expectedStarts = { 1, 5, 7 };
                        ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
                        XmlUtilsTest.verifyStateIntervals("test", ss, quark, expectedStarts, expectedValues);
                    }
                    break;
                case "test1":
                    {
                        final int[] expectedStarts = { 1, 3, 7, 7 };
                        ITmfStateValue[] expectedValues = { TmfStateValue.nullValue(), TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1) };
                        XmlUtilsTest.verifyStateIntervals("test1", ss, quark, expectedStarts, expectedValues);
                    }
                    break;
                case "checkpoint":
                    {
                        final int[] expectedStarts = { 1, 5, 7, 7 };
                        ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
                        XmlUtilsTest.verifyStateIntervals("checkpoint", ss, quark, expectedStarts, expectedValues);
                    }
                    break;
                case "and_three_operands":
                    {
                        final int[] expectedStarts = { 1, 5, 7, 7 };
                        ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1) };
                        XmlUtilsTest.verifyStateIntervals("and_three_operands", ss, quark, expectedStarts, expectedValues);
                    }
                    break;
                case "not_operand":
                    {
                        final int[] expectedStarts = { 1, 5, 7, 7 };
                        ITmfStateValue[] expectedValues = { TmfStateValue.newValueLong(0), TmfStateValue.newValueLong(1), TmfStateValue.newValueLong(0) };
                        XmlUtilsTest.verifyStateIntervals("not_operand", ss, quark, expectedStarts, expectedValues);
                    }
                    break;
                default:
                    fail("Wrong attribute name " + name);
                    break;
            }
        }
    } catch (TmfAnalysisException | AttributeNotFoundException | StateSystemDisposedException e) {
        fail(e.getMessage());
    } finally {
        module.dispose();
        trace.dispose();
    }
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test) XmlUtilsTest(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)

Example 14 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class TmfXmlConditionTest method testConditionsPattern.

/**
 * Test time range and elapsed validations
 */
@Test
public void testConditionsPattern() {
    ITmfTrace trace = XmlUtilsTest.initializeTrace(testTrace4);
    XmlPatternAnalysis module = XmlUtilsTest.initializePatternModule(TmfXmlTestFiles.VALID_PATTERN_SIMPLE_FILE);
    try {
        module.setTrace(trace);
        module.schedule();
        module.waitForCompletion();
        ISegmentStore<@NonNull ISegment> segmentStore = module.getSegmentStore();
        assertNotNull(segmentStore);
        assertEquals(1, segmentStore.size());
        Iterator<@NonNull ISegment> elements = segmentStore.getIntersectingElements(6).iterator();
        assertTrue(elements.hasNext());
        ISegment next = elements.next();
        assertEquals(5, next.getStart());
        assertEquals(2, next.getLength());
    } catch (TmfAnalysisException e) {
        fail(e.getMessage());
    } finally {
        module.dispose();
        trace.dispose();
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) Test(org.junit.Test) XmlUtilsTest(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)

Example 15 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class TmfAbstractAnalysisModule method execute.

private void execute(final ITmfTrace trace) {
    try (FlowScopeLog analysisLog = new FlowScopeLogBuilder(LOGGER, Level.FINE, "TmfAbstractAnalysis:scheduling", "name", getName()).setCategory(getId()).build()) {
        /* Do not execute if analysis has already run */
        if (fFinishedLatch.getCount() == 0) {
            // $NON-NLS-1$
            TmfCoreTracer.traceAnalysis(getId(), getTrace(), "already executed");
            return;
        }
        /* Do not execute if analysis already running */
        synchronized (syncObj) {
            if (fStarted) {
                // $NON-NLS-1$
                TmfCoreTracer.traceAnalysis(getId(), getTrace(), "already started, not starting again");
                return;
            }
            fStarted = true;
            // Reset cancellation and failure cause
            fAnalysisCancelled = false;
            fFailureCause = null;
        }
        /*
             * Execute dependent analyses before creating the job for this one
             */
        final Iterable<IAnalysisModule> dependentAnalyses = getDependentAnalyses();
        int depLevel = 0;
        for (IAnalysisModule module : dependentAnalyses) {
            module.schedule();
            // Add the dependency level of the analysis + 1 to make sure
            // that if
            // an analysis already depends on another, it is taken into
            // account
            depLevel += module.getDependencyLevel() + 1;
        }
        fDependencyLevel = depLevel;
        /*
             * Actual analysis will be run on a separate thread
             */
        String jobName = checkNotNull(NLS.bind(Messages.TmfAbstractAnalysisModule_RunningAnalysis, getName()));
        fJob = new Job(jobName) {

            @Override
            @Nullable
            protected IStatus run(@Nullable final IProgressMonitor monitor) {
                try (FlowScopeLog jobLog = new FlowScopeLogBuilder(LOGGER, Level.FINE, "TmfAbstractAnalysis:executing").setParentScope(analysisLog).build()) {
                    // $NON-NLS-1$
                    IProgressMonitor mon = SubMonitor.convert(monitor);
                    try {
                        broadcast(new TmfStartAnalysisSignal(TmfAbstractAnalysisModule.this, TmfAbstractAnalysisModule.this));
                        // $NON-NLS-1$
                        TmfCoreTracer.traceAnalysis(TmfAbstractAnalysisModule.this.getId(), TmfAbstractAnalysisModule.this.getTrace(), "started");
                        fAnalysisCancelled = !executeAnalysis(mon);
                        for (IAnalysisModule module : dependentAnalyses) {
                            module.waitForCompletion(mon);
                        }
                        // $NON-NLS-1$
                        TmfCoreTracer.traceAnalysis(TmfAbstractAnalysisModule.this.getId(), TmfAbstractAnalysisModule.this.getTrace(), "finished");
                    } catch (TmfAnalysisException e) {
                        // $NON-NLS-1$
                        Activator.logError("Error executing analysis with trace " + trace.getName(), e);
                    } catch (OperationCanceledException e) {
                    // Analysis was canceled
                    } catch (Exception e) {
                        // $NON-NLS-1$
                        Activator.logError("Unexpected error executing analysis with trace " + trace.getName(), e);
                        fail(e);
                        // Reset analysis so that it can be executed again.
                        resetAnalysis();
                        // $NON-NLS-1$
                        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, "Exception executing analysis", e);
                    } finally {
                        synchronized (syncObj) {
                            setAnalysisCompleted();
                        }
                        TmfTraceManager.refreshSupplementaryFiles(trace);
                    }
                    if (!fAnalysisCancelled) {
                        return Status.OK_STATUS;
                    }
                    // Reset analysis so that it can be executed again.
                    resetAnalysis();
                    return Status.CANCEL_STATUS;
                }
            }

            @Override
            protected void canceling() {
                // $NON-NLS-1$
                TmfCoreTracer.traceAnalysis(getId(), getTrace(), "job cancelled");
                TmfAbstractAnalysisModule.this.canceling();
            }
        };
        fJob.schedule();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) TmfStartAnalysisSignal(org.eclipse.tracecompass.tmf.core.signal.TmfStartAnalysisSignal) FlowScopeLogBuilder(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) FlowScopeLog(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog) Job(org.eclipse.core.runtime.jobs.Job) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)44 Test (org.junit.Test)21 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)15 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)14 TestAnalysis (org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis)9 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)8 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)8 File (java.io.File)7 LttngKernelTrace (org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace)6 IStatus (org.eclipse.core.runtime.IStatus)5 Performance (org.eclipse.test.performance.Performance)5 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)5 BeforeClass (org.junit.BeforeClass)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)4 Nullable (org.eclipse.jdt.annotation.Nullable)3 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)3 XmlUtilsTest (org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)3 IAnalysisModuleHelper (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2