Search in sources :

Example 16 with TmfAnalysisException

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

the class TmfTrace method executeAnalysis.

/**
 * Instantiate the applicable analysis modules and executes the analysis
 * modules that are meant to be automatically executed
 *
 * @return An IStatus indicating whether the analysis could be run
 *         successfully or not
 */
protected IStatus executeAnalysis() {
    MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
    /* First modules are initialized */
    Map<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules(this.getClass());
    for (IAnalysisModuleHelper helper : modules.values()) {
        try {
            IAnalysisModule module = helper.newModule(this);
            if (module == null) {
                continue;
            }
            fAnalysisModules.put(module.getId(), module);
        } catch (TmfAnalysisException e) {
            status.add(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage()));
        }
    }
    /* Once all modules are initialized, automatic modules are executed */
    for (IAnalysisModule module : getAnalysisModules()) {
        if (module.isAutomatic()) {
            status.add(module.schedule());
        }
    }
    return status;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) MultiStatus(org.eclipse.core.runtime.MultiStatus) IAnalysisModuleHelper(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper)

Example 17 with TmfAnalysisException

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

the class TmfStateStatisticsTest method setUp.

/**
 * Test setup
 */
@BeforeClass
public static void setUp() {
    ITmfTrace trace = CtfTmfTestTraceUtils.getTrace(testTrace);
    fTrace = trace;
    /* Prepare the two analysis-backed state systems */
    fTotalsMod = new TmfStatisticsTotalsModule();
    fEventTypesMod = new TmfStatisticsEventTypesModule();
    try {
        fTotalsMod.setTrace(trace);
        fEventTypesMod.setTrace(trace);
    } catch (TmfAnalysisException e) {
        fail(e.getMessage());
    }
    fTotalsMod.schedule();
    fEventTypesMod.schedule();
    assertTrue(fTotalsMod.waitForCompletion());
    assertTrue(fEventTypesMod.waitForCompletion());
    ITmfStateSystem totalsSS = fTotalsMod.getStateSystem();
    ITmfStateSystem eventTypesSS = fEventTypesMod.getStateSystem();
    assertNotNull(totalsSS);
    assertNotNull(eventTypesSS);
    backend = new TmfStateStatistics(totalsSS, eventTypesSS);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfStatisticsTotalsModule(org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsTotalsModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) TmfStateStatistics(org.eclipse.tracecompass.tmf.core.statistics.TmfStateStatistics) TmfStatisticsEventTypesModule(org.eclipse.tracecompass.tmf.core.statistics.TmfStatisticsEventTypesModule) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) BeforeClass(org.junit.BeforeClass)

Example 18 with TmfAnalysisException

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

the class AnalysisModuleHelperTest method testParameters.

/**
 * Test for the initialization of parameters from the extension points
 */
@Test
public void testParameters() {
    ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
    /*
         * This analysis has a parameter, but no default value. we should be
         * able to set the parameter
         */
    IAnalysisModuleHelper helper = getModuleHelper(AnalysisManagerTest.MODULE_PARAM);
    assertNotNull(helper);
    IAnalysisModule module = null;
    try {
        module = helper.newModule(trace);
        assertNotNull(module);
        assertNull(module.getParameter(TestAnalysis.PARAM_TEST));
        module.setParameter(TestAnalysis.PARAM_TEST, 1);
        assertEquals(1, module.getParameter(TestAnalysis.PARAM_TEST));
    } catch (TmfAnalysisException e1) {
        fail(e1.getMessage());
        return;
    } finally {
        if (module != null) {
            module.dispose();
        }
    }
    /* This module has a parameter with default value */
    helper = getModuleHelper(AnalysisManagerTest.MODULE_PARAM_DEFAULT);
    assertNotNull(helper);
    try {
        module = helper.newModule(trace);
        assertNotNull(module);
        assertEquals(3, module.getParameter(TestAnalysis.PARAM_TEST));
        module.setParameter(TestAnalysis.PARAM_TEST, 1);
        assertEquals(1, module.getParameter(TestAnalysis.PARAM_TEST));
    } catch (TmfAnalysisException e1) {
        fail(e1.getMessage());
        return;
    } finally {
        if (module != null) {
            module.dispose();
        }
    }
    /*
         * This module does not have a parameter so setting it should throw an
         * error
         */
    helper = getModuleHelper(AnalysisManagerTest.MODULE_SECOND);
    assertNotNull(helper);
    Exception exception = null;
    trace = fTrace;
    assertNotNull(trace);
    try {
        module = helper.newModule(trace);
        assertNotNull(module);
        assertNull(module.getParameter(TestAnalysis.PARAM_TEST));
        try {
            module.setParameter(TestAnalysis.PARAM_TEST, 1);
        } catch (RuntimeException e) {
            exception = e;
        }
    } catch (TmfAnalysisException e1) {
        fail(e1.getMessage());
        return;
    } finally {
        if (module != null) {
            module.dispose();
        }
    }
    assertNotNull(exception);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) IAnalysisModuleHelper(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

Example 19 with TmfAnalysisException

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

the class AnalysisModuleHelperTest method testNewModule.

/**
 * Test the
 * {@link TmfAnalysisModuleHelperConfigElement#newModule(ITmfTrace)} method
 * for the 2 modules
 */
@Test
public void testNewModule() {
    /* Test analysis module with traceStub */
    IAnalysisModule module = null;
    try {
        module = fModule.newModule(TmfTestTrace.A_TEST_10K.getTrace());
        assertNotNull(module);
        assertTrue(module instanceof TestAnalysis);
    } catch (TmfAnalysisException e) {
        fail();
    } finally {
        if (module != null) {
            module.dispose();
        }
    }
    /* TestAnalysis2 module with trace, should return an exception */
    try {
        module = fModuleOther.newModule(TmfTestTrace.A_TEST_10K.getTrace());
        assertNull(module);
    } catch (TmfAnalysisException e) {
        fail();
    } finally {
        if (module != null) {
            module.dispose();
        }
    }
    /* TestAnalysis2 module with a TraceStub2 */
    ITmfTrace trace = fTrace;
    assertNotNull(trace);
    try {
        module = fModuleOther.newModule(trace);
        assertNotNull(module);
        assertTrue(module instanceof TestAnalysis2);
    } catch (TmfAnalysisException e) {
        fail();
    } finally {
        if (module != null) {
            module.dispose();
        }
    }
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TestAnalysis2(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis2) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

Example 20 with TmfAnalysisException

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

the class AnalysisModuleHelperTest method testAppliesToExperiment.

/**
 * Test the analysis modules with a differing result for experiments
 */
@Test
public void testAppliesToExperiment() {
    ITmfTrace trace1 = TmfTestTrace.A_TEST_10K.getTrace();
    ITmfTrace trace2 = TmfTestTrace.A_TEST_10K2.getTrace();
    ITmfTrace trace3 = TmfTestTrace.A_TEST_10K2.getTraceAsStub2();
    /* Create an experiment with TmfTraceStub */
    ITmfTrace[] tracesExp1 = { trace1, trace2 };
    TmfExperiment exp1 = new TmfExperiment(tracesExp1[0].getEventType(), "Experiment 1", tracesExp1, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    /* Create an experiment containing some TmfTraceStub2 */
    ITmfTrace[] tracesExp2 = { trace1, trace3 };
    TmfExperiment exp2 = new TmfExperiment(tracesExp2[0].getEventType(), "Experiment 1", tracesExp2, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
    try {
        /* fModule should return null for both experiments */
        IAnalysisModule module = null;
        try {
            module = fModule.newModule(exp1);
            assertNull(module);
        } catch (TmfAnalysisException e) {
            fail();
        } finally {
            if (module != null) {
                module.dispose();
            }
        }
        try {
            module = fModule.newModule(exp2);
            assertNull(module);
        } catch (TmfAnalysisException e) {
            fail();
        } finally {
            if (module != null) {
                module.dispose();
            }
        }
        /* fModuleOther should throw exception for exp1, but not exp2 */
        try {
            module = fModuleOther.newModule(exp1);
            assertNull(module);
        } catch (TmfAnalysisException e) {
            fail();
        } finally {
            if (module != null) {
                module.dispose();
            }
        }
        try {
            module = fModuleOther.newModule(exp2);
            assertNotNull(module);
        } catch (TmfAnalysisException e) {
            fail();
        } finally {
            if (module != null) {
                module.dispose();
            }
        }
    } finally {
        exp2.dispose();
        exp1.dispose();
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

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