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;
}
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);
}
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);
}
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();
}
}
}
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();
}
}
Aggregations