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