import org.eclipse.tracecompass.analysis.graph.core.tests.stubs.TestGraphWorker;
import org.eclipse.tracecompass.analysis.graph.core.tests.stubs.module.GraphBuilderModuleStub;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
*
* @return
*/
- private TmfGraphBuilderModule getModule() {
- ITmfTrace trace = TmfXmlTraceStub.setupTrace(Activator.getAbsoluteFilePath(STUB_TRACE_FILE));
- ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
+ private TmfGraphBuilderModule getModule(TmfTrace trace) {
+ trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
GraphBuilderModuleStub module = null;
for (GraphBuilderModuleStub mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, GraphBuilderModuleStub.class)) {
module = mod;
*/
@Test
public void testBuildGraph() {
+ TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(Activator.getAbsoluteFilePath(STUB_TRACE_FILE));
- TmfGraphBuilderModule module = getModule();
+ TmfGraphBuilderModule module = getModule(trace);
module.schedule();
module.waitForCompletion();
assertEquals(hasEdges2[i][3], v.getEdge(EdgeDirection.OUTGOING_VERTICAL_EDGE) != null);
}
+ trace.dispose();
}
}
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.junit.After;
import org.junit.Before;
*/
public class SyscallAnalysisTest {
+ private ITmfTrace fTestTrace;
private SystemCallLatencyAnalysis fSyscallModule;
/**
*/
@Before
public void setUp() {
- ITmfTrace trace = KernelCtfTraceStub.getTrace(CtfTestTrace.ARM_64_BIT_HEADER);
+ KernelCtfTraceStub trace = KernelCtfTraceStub.getTrace(CtfTestTrace.ARM_64_BIT_HEADER);
+ fTestTrace = trace;
/* Make sure the Kernel analysis has run */
- ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
+ trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, SystemCallLatencyAnalysis.class)) {
fSyscallModule = (SystemCallLatencyAnalysis) mod;
}
*/
@After
public void cleanup() {
- final SystemCallLatencyAnalysis syscallModule = fSyscallModule;
- if( syscallModule != null) {
- syscallModule.dispose();
+ final ITmfTrace testTrace = fTestTrace;
+ if (testTrace != null) {
+ testTrace.dispose();
}
}
import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.junit.After;
import org.junit.Before;
*/
public class SyscallStatsAnalysisTest {
- private TmfTrace fTestTrace;
+ private ITmfTrace fTestTrace;
private SystemCallLatencyStatisticsAnalysisModule fSyscallStatsModule;
/**
*/
@Before
public void setupAnalysis() {
- ITmfTrace trace = KernelCtfTraceStub.getTrace(CtfTestTrace.ARM_64_BIT_HEADER);
+ KernelCtfTraceStub trace = KernelCtfTraceStub.getTrace(CtfTestTrace.ARM_64_BIT_HEADER);
+ fTestTrace = trace;
/* Make sure the Kernel analysis has run */
- ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
+ trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
IAnalysisModule module = null;
for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, SystemCallLatencyAnalysis.class)) {
module = mod;
*/
@After
public void cleanup() {
- final TmfTrace testTrace = fTestTrace;
+ final ITmfTrace testTrace = fTestTrace;
if (testTrace != null) {
testTrace.dispose();
}
import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
-import org.junit.BeforeClass;
+import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
}
/**
- * Things to setup
+ * Clean up
*/
- @BeforeClass
- public static void beforeClass() {
- SegmentTableTest.beforeClass();
+ @AfterClass
+ public static void afterClass() {
+ fSystemCallLatencyAnalysis.dispose();
}
@Override
import org.eclipse.tracecompass.tmf.ui.views.timegraph.ITimeGraphEntryComparator;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
+import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
private static final @NonNull CtfTestTrace TEST_TRACE1 = CtfTestTrace.SYNC_DEST;
private static final @NonNull CtfTestTrace TEST_TRACE2 = CtfTestTrace.SYNC_SRC;
- private static final @NonNull CtfTestTrace TEST_TRACE3 = CtfTestTrace.DEBUG_INFO;
+ private static final @NonNull CtfTestTrace TEST_TRACE3 = CtfTestTrace.DEBUG_INFO4;
private static ITmfTrace TRACE1;
private static ITmfTrace TRACE2;
TRACE3 = CtfTmfTestTraceUtils.getTrace(TEST_TRACE3);
}
+ /**
+ * Clean up
+ */
+ @AfterClass
+ public static void afterClass() {
+ TRACE1.dispose();
+ TRACE2.dispose();
+ TRACE3.dispose();
+ }
+
/**
* Test {@link IControlFlowEntryComparator#PROCESS_NAME_COMPARATOR}
*/
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeLinkEvent;
+import org.junit.AfterClass;
import org.junit.Test;
import com.google.common.collect.ImmutableMap;
return new NaiveOptimizationAlgorithm();
}
+ /**
+ * Clean up
+ */
+ @AfterClass
+ public static void afterClass() {
+ TRACE.dispose();
+ }
+
/**
* Test an empty vector.
*/
assertEquals("Depth:First parent", 0, f1.getDepth());
assertEquals("Depth:Second parent", 1, f2.getDepth());
assertEquals("Depth:Last child", 2, f3.getDepth());
+ cga.dispose();
}
/**
assertEquals("Function's self time", 10, f1.getSelfTime());
assertEquals("Compare the function's self time and total time", f1.getLength(), f1.getSelfTime());
assertEquals("Function's depth", 0, f1.getDepth());
+ cga.dispose();
}
/**
assertEquals("Test of parenthood", NonNullUtils.checkNotNull(firstChild.getParent()).getSymbol(), threads.get(0).getSymbol());
assertEquals("Test of parenthood", NonNullUtils.checkNotNull(secondChild.getParent()).getSymbol(), threads.get(1).getSymbol());
-
+ cga.dispose();
}
/**
for (int i = 1; i < LARGE_AMOUNT_OF_SEGMENTS; i++) {
assertEquals("Test parenthood", ((ICalledFunction) segments[i - 1]).getSymbol(), NonNullUtils.checkNotNull(((ICalledFunction) segments[i]).getParent()).getSymbol());
}
+ cga.dispose();
}
/**
assertNotNull(segmentStore);
Object[] segments = segmentStore.toArray();
assertEquals("Number of root functions", 0, segments.length);
+ cga.dispose();
}
/**
// Test if the first child and the third one have the same address
assertEquals("Test the address of two functions", firstChild.getSymbol(), thirdChild.getSymbol());
-
+ cga.dispose();
}
}
assertEquals("Test second function's average self time", 30, functionStatistics2.getAverageSelfTime(), ERROR);
assertEquals("Test second function's standard deviation", Double.NaN, functionStatistics2.getStdDev(), ERROR);
assertEquals("Test second function's self time standard deviation", Double.NaN, functionStatistics2.getStdDevSelfTime(), ERROR);
+ cga.dispose();
}
/**
assertEquals("Test second leaf's average self time", 20, leafStatistics2.getAverageSelfTime(), ERROR);
assertEquals("Test second leaf's standard deviation", Double.NaN, leafStatistics2.getStdDev(), ERROR);
assertEquals("Test second leaf's self time standard deviation", Double.NaN, leafStatistics2.getStdDevSelfTime(), ERROR);
-
+ cga.dispose();
}
/**
assertEquals("Test third function's average self time", 10, functionStatistics3.getAverageSelfTime(), ERROR);
assertEquals("Test third function's standard deviation", Double.NaN, functionStatistics3.getStdDev(), ERROR);
assertEquals("Test third function's self time standard deviation", Double.NaN, functionStatistics3.getStdDevSelfTime(), ERROR);
+ cga.dispose();
}
/**
assertEquals("Test fourth function's average duration", 15, fourthFunctionStatistics4.getAverageSelfTime(), ERROR);
assertEquals("Test fourth function's standard deviation", Double.NaN, fourthFunctionStatistics4.getStdDev(), ERROR);
assertEquals("Test fourth function's self time deviation", Double.NaN, fourthFunctionStatistics4.getStdDevSelfTime(), ERROR);
+ cga.dispose();
}
}
List<ThreadNode> threads = cga.getThreadNodes();
assertNotNull(threads);
assertEquals("Number of threads found", 0, threads.size());
+ cga.dispose();
}
/**
assertEquals("Test first function's nombre of calls", 1, firstFunction.getNbCalls());
assertEquals("Test second function's nombre of calls", 1, secondFunction.getNbCalls());
assertEquals("Test third function's nombre of calls", 1, thirdFunction.getNbCalls());
+ cga.dispose();
}
/**
assertEquals("Test first function's number of calls", 1, firstFunction.getNbCalls());
assertEquals("Test second function's number of calls", 2, secondFunction.getNbCalls());
assertEquals("Test third function's number of calls", 1, thirdFunction.getNbCalls());
+ cga.dispose();
}
/**
assertEquals("Test second function's number of calls", 2, secondFunction.getNbCalls());
assertEquals("Test first leaf's number of calls", 1, leaf1.getNbCalls());
assertEquals("Test second leaf's number of calls", 1, leaf2.getNbCalls());
+ cga.dispose();
}
/**
assertEquals("Test first child's number of calls", 2, function2.getNbCalls());
assertEquals("Test second child's number of calls", 1, function3.getNbCalls());
assertEquals("Test leaf's number of calls", 2, function4.getNbCalls());
+ cga.dispose();
}
/**
assertEquals("Test parenthood", NonNullUtils.checkNotNull(child.getParent()).getSymbol(), NonNullUtils.checkNotNull(parent.getSymbol()));
parent = child;
}
+ cga.dispose();
}
/**
assertEquals("Test first function's number of calls", 2, firstFunction.getNbCalls());
assertEquals("Test second function's number of calls", 1, function2.getNbCalls());
assertEquals("Test third function's number of calls", 1, function3.getNbCalls());
-
+ cga.dispose();
}
/**
assertEquals("Test first function's number of calls", 1, secondFunction.getNbCalls());
assertEquals("Test third function's number of calls", 1, function3.getNbCalls());
assertEquals("Test third function's number of calls", 1, function4.getNbCalls());
-
+ cga.dispose();
}
/**
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
import org.junit.Test;
public void testExecuteNoTrace() throws TmfAnalysisException {
StubSegmentStatisticsAnalysis fixture = new StubSegmentStatisticsAnalysis();
assertFalse(fixture.executeAnalysis(new NullProgressMonitor()));
+ fixture.dispose();
}
/**
@Test
public void testExecuteNoDepend() throws TmfAnalysisException {
StubSegmentStatisticsAnalysis fixture = new StubSegmentStatisticsAnalysis();
- fixture.setTrace(new TmfXmlTraceStub());
+ TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ fixture.setTrace(trace);
assertFalse(fixture.executeAnalysis(new NullProgressMonitor()));
+ trace.dispose();
+ fixture.dispose();
}
/**
fixture.setTrace(trace);
fixture.getDependentAnalyses();
assertTrue(fixture.executeAnalysis(new NullProgressMonitor()));
+ trace.dispose();
+ fixture.dispose();
}
/**
*/
@Test
public void testTotalStats() throws TmfAnalysisException {
- StubSegmentStatisticsAnalysis fixture = getValidSegmentStats();
+ TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
SegmentStoreStatistics totalStats = fixture.getTotalStats();
assertNotNull(totalStats);
// no need to test the content much as it is tested in the other test.
assertEquals(StubSegmentStatisticsAnalysis.SIZE, totalStats.getNbSegments());
+ trace.dispose();
+ fixture.dispose();
}
/**
*/
@Test
public void testPerTypeStats() throws TmfAnalysisException {
- StubSegmentStatisticsAnalysis fixture = getValidSegmentStats();
+ TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = fixture.getPerSegmentTypeStats();
assertNotNull(perTypeStats);
// no need to test the content much as it is tested in the other test.
assertNotNull(segmentStoreStatistics);
// starts with 0 so size + 1
assertEquals(StubSegmentStatisticsAnalysis.SIZE / 2 + 1, segmentStoreStatistics.getNbSegments());
+ trace.dispose();
+ fixture.dispose();
}
/**
*/
@Test
public void testPartialStats() throws TmfAnalysisException {
- StubSegmentStatisticsAnalysis fixture = getValidSegmentStats();
+ TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
SegmentStoreStatistics totalStats = fixture.getTotalStatsForRange(100, 1100, new NullProgressMonitor());
assertNotNull(totalStats);
// no need to test the content much as it is tested in the other test.
// 1051 = 1001 where start is between start and end + 50 overlapping
// start
assertEquals(1051, totalStats.getNbSegments());
+ trace.dispose();
+ fixture.dispose();
}
/**
*/
@Test
public void testPartialPerTypeStats() throws TmfAnalysisException {
- StubSegmentStatisticsAnalysis fixture = getValidSegmentStats();
+ TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = fixture.getPerSegmentTypeStatsForRange(100, 1100, new NullProgressMonitor());
assertNotNull(perTypeStats);
// no need to test the content much as it is tested in the other test.
assertNotNull(segmentStoreStatistics);
// 526 = 1051/2+1 = see explanation of 1051 in #testPartialStats
assertEquals(526, segmentStoreStatistics.getNbSegments());
+ trace.dispose();
+ fixture.dispose();
}
/**
*/
@Test
public void testPartialPerTypeStatsCancel() throws TmfAnalysisException {
- StubSegmentStatisticsAnalysis fixture = getValidSegmentStats();
+ TmfXmlTraceStub trace = new TmfXmlTraceStub();
+ StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
NullProgressMonitor monitor = new NullProgressMonitor();
monitor.setCanceled(true);
Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = fixture.getPerSegmentTypeStatsForRange(100, 1100, monitor);
assertEquals(Collections.emptyMap(), perTypeStats);
+ trace.dispose();
+ fixture.dispose();
}
- private static StubSegmentStatisticsAnalysis getValidSegmentStats() throws TmfAnalysisException {
+ private static StubSegmentStatisticsAnalysis getValidSegmentStats(@NonNull ITmfTrace trace) throws TmfAnalysisException {
StubSegmentStatisticsAnalysis fixture = new StubSegmentStatisticsAnalysis();
- TmfXmlTraceStub trace = new TmfXmlTraceStub();
fixture.setTrace(trace);
fixture.getDependentAnalyses();
fixture.executeAnalysis(new NullProgressMonitor());
private final List<@NonNull ISegment> fPreFixture;
private final ISegmentStore<@NonNull ISegment> fFixture = SegmentStoreFactory.createSegmentStore();
- private StubProvider fSegmentStoreProvider;
+ private @NonNull StubProvider fSegmentStoreProvider;
public StubSegmentStatisticsAnalysis() {
ImmutableList.Builder<@NonNull ISegment> builder = new Builder<>();
fSegmentStoreProvider = new StubProvider(fFixture);
}
+ @Override
+ public void dispose() {
+ super.dispose();
+ fSegmentStoreProvider.dispose();
+ }
+
@Override
public boolean setTrace(@NonNull ITmfTrace trace) throws TmfAnalysisException {
if (trace instanceof TmfXmlTraceStub) {
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.AbstractSegmentStatisticsAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.SegmentStoreStatistics;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.SubSecondTimeWithUnitFormat;
}
});
Menu tablePopup = fTablePopupMenuManager.createContextMenu(getTreeViewer().getTree());
- getTreeViewer().getTree().setMenu(tablePopup);
+ Tree tree = getTreeViewer().getTree();
+ tree.setMenu(tablePopup);
+ tree.addDisposeListener(e -> {
+ if (fModule != null) {
+ fModule.dispose();
+ }
+ });
}
/** Provides label for the Segment Store tree viewer cells */
try {
module.setTrace(trace);
module.schedule();
+ if (fModule != null) {
+ fModule.dispose();
+ }
fModule = module;
} catch (TmfAnalysisException e) {
Activator.getDefault().logError("Error initializing statistics analysis module", e); //$NON-NLS-1$
* Dispose of all the manager's resources (i.e. its connections).
*/
public void dispose() {
+ TmfSignalManager.deregister(fConnectionManager);
for (LttngRelaydConsumer consumer : fConnections.values()) {
consumer.dispose();
}
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.junit.Test;
* @return The trace with its graph module executed
*/
public ITmfTrace setUpTrace(String traceFile) {
- ITmfTrace trace = new TmfXmlKernelTraceStub();
+ TmfXmlKernelTraceStub trace = new TmfXmlKernelTraceStub();
IPath filePath = Activator.getAbsoluteFilePath(traceFile);
IStatus status = trace.validate(null, filePath.toOSString());
if (!status.isOK()) {
} catch (TmfTraceException e) {
fail(e.getMessage());
}
- ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
+ trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
IAnalysisModule module = null;
for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, TmfGraphBuilderModule.class)) {
module = mod;
break;
}
}
+ trace.dispose();
}
}
SWTBotUtils.createProject(TRACE_PROJECT_NAME);
File fTestFile = new File(CtfTmfTestTraceUtils.getTrace(CTF_TRACE).getPath());
+ CtfTmfTestTraceUtils.dispose(CTF_TRACE);
String path = fTestFile.getAbsolutePath();
TmfSignalManager.register(this);
}
+ @Override
+ public void dispose() {
+ super.dispose();
+ TmfSignalManager.deregister(this);
+ }
+
@Override
public String getName() {
return NAME;
assertEquals(2.71828, val.get(0).getStateValue().unboxDouble(), Double.MIN_VALUE);
val = ss.queryFullState(6);
assertEquals(1.41421, val.get(0).getStateValue().unboxDouble(), Double.MIN_VALUE);
+ trace.dispose();
+ module.dispose();
}
}
assertEquals(getAnalysisId(), fModule.getId());
assertEquals(getAnalysisName(), fModule.getName());
+
+ fModule.dispose();
}
private void createModule(@NonNull Element element) {
} finally {
trace.dispose();
}
-
+ fModule.dispose();
+ CtfTmfTestTraceUtils.dispose(getTrace());
}
}
}
}
+ /**
+ * Clean up
+ */
+ @After
+ public void cleanup() {
+ fModule.dispose();
+ CtfTmfTestTraceUtils.dispose(getTrace());
+ }
+
/**
* The node name of the analysis in the file
*
* by 1
*/
assertEquals(countBefore + 1, NewModuleListenerStub.getModuleCount());
+
+ module.dispose();
}
}
package org.eclipse.tracecompass.tmf.core.tests.analysis.requirements;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventFieldRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement.PriorityLevel;
+import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventFieldRequirement;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTraceWithPreDefinedEvents;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
import org.junit.Test;
import com.google.common.collect.ImmutableSet;
private final @NonNull TmfTrace trace = new TraceWithEvents();
+ /**
+ * Clean up
+ */
+ @After
+ public void cleanup() {
+ trace.dispose();
+ }
+
/**
* Test with optional requirements
*/
req = new TmfAnalysisEventFieldRequirement(EVENT1, ImmutableSet.of(EVENT1_FIELD1), PriorityLevel.OPTIONAL);
assertTrue(req.test(traceNoEvents));
+
+ traceNoEvents.dispose();
}
}
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement.PriorityLevel;
+import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisEventRequirement;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTraceWithPreDefinedEvents;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
import org.junit.Test;
import com.google.common.collect.ImmutableSet;
private final @NonNull TmfTrace fTrace = new TraceWithEvents();
+ /**
+ * Clean up
+ */
+ @After
+ public void cleanup() {
+ fTrace.dispose();
+ }
+
/**
* Test with optional requirements
*/
req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT1, EVENT2), PriorityLevel.OPTIONAL);
assertTrue(req.test(traceNoEvents));
+ traceNoEvents.dispose();
}
}
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement;
import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAbstractAnalysisRequirement.PriorityLevel;
+import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfCompositeAnalysisRequirement;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.common.collect.ImmutableSet;
-import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfCompositeAnalysisRequirement;
-
/**
* Test the {@link TmfCompositeAnalysisRequirement} class
*
fTrace = new TmfTraceStub();
}
+ /**
+ * Clean up
+ */
+ @After
+ public void cleanup() {
+ if (fTrace != null) {
+ fTrace.dispose();
+ }
+ }
+
/**
* Test composite requirement with {@link PriorityLevel#MANDATORY} level
*/
/*******************************************************************************
- * Copyright (c) 2013, 2015 Ericsson
+ * Copyright (c) 2013, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
+import org.junit.After;
import org.junit.Before;
/**
/**
- * set up directories
+ * set up definition
*/
@Before
public void init() {
t = new CustomXmlTrace(cxtd);
}
+ /**
+ * clean up
+ */
+ @After
+ public void cleanup() {
+ if (t != null) {
+ t.dispose();
+ }
+ }
/**
* @return the trace
this.type = type;
}
+ @Override
+ public void dispose() {
+ super.dispose();
+ getTrace().dispose();
+ }
+
@Override
protected void eventHandle(ITmfEvent ev) {
ITmfStateSystemBuilder ss = checkNotNull(getStateSystemBuilder());
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.tests.stubs.event.TmfSyncEventStub;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
fTraces = traces;
}
+ /**
+ * Clean up
+ */
+ @After
+ public void cleanup() {
+ if (t1 != null) {
+ t1.dispose();
+ }
+ if (t2 != null) {
+ t2.dispose();
+ }
+ }
+
/**
* Testing fully incremental algorithm with communication between the two
* traces
fail("TmfTrace.initialize() - no exception thrown");
} catch (TmfTraceException e) {
// Success
+ trace.dispose();
} catch (Exception e) {
fail("TmfTrace.initialize() - wrong exception thrown");
}
for (File f : validFiles) {
assertTrue(trace.validate(null, f.getAbsolutePath()).isOK());
}
+
+ trace.dispose();
}
/**
fail(e.getMessage());
}
assertEquals(4, req.getCount());
+
+ trace.dispose();
}
/**
assertNotNull(event);
assertEquals("Cpu aspect of event 4", 1, cpuAspect.resolve(event));
assertEquals("Test aspect of event 4", "def", testAspect.resolve(event));
+
+ ctx.dispose();
+ trace.dispose();
}
private static IStatus testEvent(ITmfEvent event) {
ITmfTimestamp initRange = TmfTimestamp.fromSeconds(60);
assertEquals("getInitialRangeOffset", initRange, trace.getInitialRangeOffset());
+
+ trace.dispose();
}
@Test
String invalidTrace = fTestFile.getParentFile().getAbsolutePath();
status = trace.validate(null, invalidTrace);
assertFalse(status.isOK());
+
+ trace.dispose();
}
@Test
assertEquals("getPath", fTestFile.toURI().getPath(), trace.getPath());
assertEquals("getName", NAME, trace.getName());
assertEquals("getCacheSize", 100, trace.getCacheSize());
+ trace.dispose();
}
// ------------------------------------------------------------------------
try {
trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
} catch (TmfTraceException e) {
+ trace.dispose();
fail(e.getMessage());
}
return trace;
* definition.
*/
public TmfXmlTraceStub() {
-
+ boolean nonNullTraceIsNonNull = false;
/* Load custom XML definition */
try (InputStream in = TmfXmlTraceStub.class.getResourceAsStream(DEVELOPMENT_TRACE_PARSER_PATH);) {
CustomXmlTraceDefinition[] definitions = CustomXmlTraceDefinition.loadAll(in);
return new TmfCheckpointIndexer(this, interval);
}
};
+ TmfSignalManager.deregister(fTrace);
+ nonNullTraceIsNonNull = true;
/* The second definition parses 'event' trace events */
fDefinition = checkNotNull(definitions[1]);
} catch (IOException e) {
+ if (nonNullTraceIsNonNull) {
+ fTrace.dispose();
+ }
throw new IllegalStateException("Cannot open the trace parser for development traces"); //$NON-NLS-1$
}
@Override
public void stop(BundleContext context) throws Exception {
TmfCoreTracer.stop();
+ TmfTraceManager.getInstance().dispose();
+ TmfAnalysisManager.dispose();
TmfSignalManager.dispose();
setDefault(null);
super.stop(context);
}
+ /**
+ * Disposes the analysis parameter providers
+ *
+ * @since 2.2
+ */
+ public static void dispose() {
+ fParamProviderInstances.values().forEach(provider -> provider.dispose());
+ }
+
/**
* Return the analysis parameter providers advertised in the extension
* point, and associated with an analysis ID.
}
if (analysisId.equals(id)) {
IAnalysisParameterProvider provider = fParamProviderInstances.get(className);
- if (provider != null) {
- providers.add(provider);
- } else {
+ if (provider == null) {
provider = checkNotNull((IAnalysisParameterProvider) ce.createExecutableExtension(CLASS_ATTR));
fParamProviderInstances.put(className, provider);
- providers.add(provider);
}
+ providers.add(provider);
}
} catch (InvalidRegistryObjectException | CoreException e) {
Activator.logError("Error creating module parameter provider", e); //$NON-NLS-1$
*/
void registerModule(IAnalysisModule module);
+
+ /**
+ * Dispose of the parameter provider
+ *
+ * @since 2.2
+ */
+ default void dispose() {
+ /* override to perform any necessary cleanup */
+ }
}
}
+ /**
+ * Disposes the analysis manager
+ *
+ * @since 2.2
+ */
+ public static void dispose() {
+ TmfAnalysisParameterProviders.dispose();
+ fParamProviderInstances.values().forEach(provider -> provider.dispose());
+ }
+
/**
* Registers a new source of modules
*
public Iterable<TmfAbstractAnalysisRequirement> getAnalysisRequirements() {
IAnalysisModule module = createModule();
if (module != null) {
- return module.getAnalysisRequirements();
+ Iterable<@NonNull TmfAbstractAnalysisRequirement> requirements = module.getAnalysisRequirements();
+ module.dispose();
+ return requirements;
}
return Collections.EMPTY_SET;
if (childCe.getName().equals(ANALYSIS_ID_ELEM)) {
listener = new TmfNewAnalysisOutputListener(output, childCe.getAttribute(ID_ATTR), null);
} else if (childCe.getName().equals(MODULE_CLASS_ELEM)) {
- listener = new TmfNewAnalysisOutputListener(output, null, childCe.createExecutableExtension(CLASS_ATTR).getClass().asSubclass(IAnalysisModule.class));
+ String contributorName = childCe.getContributor().getName();
+ Class<?> moduleClass = Platform.getBundle(contributorName).loadClass(childCe.getAttribute(CLASS_ATTR));
+ listener = new TmfNewAnalysisOutputListener(output, null, moduleClass.asSubclass(IAnalysisModule.class));
}
}
- } catch (InvalidRegistryObjectException | CoreException e) {
+ } catch (InvalidRegistryObjectException | CoreException | ClassNotFoundException e) {
Activator.logError("Error creating module output listener", e); //$NON-NLS-1$
}
return listener;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects;
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
public TmfTrace(final TmfTrace trace) throws TmfTraceException {
super();
if (trace == null) {
+ super.dispose();
throw new IllegalArgumentException();
}
fCacheSize = trace.getCacheSize();
final Class<? extends ITmfEvent> type)
throws TmfTraceException {
if (path == null) {
+ dispose();
throw new TmfTraceException("Invalid trace path"); //$NON-NLS-1$
}
fPath = path;
return mgr;
}
+ /**
+ * Disposes the trace manager
+ *
+ * @since 2.2
+ */
+ public void dispose() {
+ TmfSignalManager.deregister(this);
+ fTraces.clear();
+ fCurrentTrace = null;
+ }
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tracecompass.internal.tmf.ui.markers.LostEventsMarkerEventSourceFactory;
+import org.eclipse.tracecompass.internal.tmf.ui.views.TmfAlignmentSynchronizer;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceAdapterManager;
import org.eclipse.tracecompass.tmf.ui.TmfUiRefreshHandler;
import org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement;
import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventAdapterFactory;
import org.eclipse.ui.plugin.AbstractUIPlugin;
public void stop(BundleContext context) throws Exception {
TmfUiTracer.stop();
TmfUiRefreshHandler.getInstance().dispose();
+ TmfAlignmentSynchronizer.getInstance().dispose();
+ TmfProjectRegistry.dispose();
plugin = null;
Platform.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory);
composite.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
- TmfSignalManager.deregister(this);
+ TmfSignalManager.deregister(OffsetDialog.this);
}
});
return area;
/*******************************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
private static final long THROTTLE_DELAY = 500;
private static final int NEAR_THRESHOLD = 10;
+
+ /** Singleton instance */
+ private static TmfAlignmentSynchronizer fInstance = null;
+
private final Timer fTimer;
private final List<AlignmentOperation> fPendingOperations = Collections.synchronizedList(new ArrayList<AlignmentOperation>());
/**
* Constructor
*/
- public TmfAlignmentSynchronizer() {
+ private TmfAlignmentSynchronizer() {
TmfSignalManager.register(this);
fTimer = new Timer();
createPreferenceListener();
};
}
+ /**
+ * Get the alignment synchronizer's instance
+ *
+ * @return The singleton instance
+ */
+ public static synchronized TmfAlignmentSynchronizer getInstance() {
+ if (fInstance == null) {
+ fInstance = new TmfAlignmentSynchronizer();
+ }
+ return fInstance;
+ }
+
+ /**
+ * Disposes the alignment synchronizer
+ */
+ public void dispose() {
+ TmfSignalManager.deregister(this);
+ fTimer.cancel();
+ fCurrentTask.cancel();
+ }
+
private IPreferenceChangeListener createPreferenceListener() {
IPreferenceChangeListener listener = new IPreferenceChangeListener() {
default boolean hasChildren() {
return !getChildren().isEmpty();
}
+
+ /**
+ * Recursively dispose of the element and its children.
+ *
+ * @since 2.2
+ */
+ default void dispose() {
+ getChildren().forEach(element -> element.dispose());
+ /* override to perform any necessary cleanup */
+ }
}
}
// ------------------------------------------------------------------------
- // TmfProjectModelElement
+ // ITmfProjectModelElement
// ------------------------------------------------------------------------
+ @Override
+ public void dispose() {
+ super.dispose();
+ TmfSignalManager.deregister(this);
+ }
+
/**
* @since 2.0
*/
/**
* Remove an element from the current child elements.
+ * <p>
+ * Disposes the removed element. It should no longer be used.
*
* @param child
* The child to remove
*/
protected void removeChild(ITmfProjectModelElement child) {
fChildren.remove(child);
+ child.dispose();
}
/**
/*******************************************************************************
- * Copyright (c) 2011, 2014 Ericsson
+ * Copyright (c) 2011, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
public class TmfProjectRegistry implements IResourceChangeListener {
// Create the singleton instance
- static {
- new TmfProjectRegistry();
- }
+ private static final TmfProjectRegistry INSTANCE = new TmfProjectRegistry();
// The map of project resource to project model elements
private static Map<IProject, TmfProjectElement> registry = new HashMap<>();
ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
}
+ /**
+ * Disposes the project registry
+ *
+ * @since 2.2
+ */
+ public static void dispose() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(INSTANCE);
+ registry.values().forEach(projectElement -> projectElement.dispose());
+ }
+
/**
* Get the project model element for a project resource
* @param project the project resource
TmfProjectElement projectElement = getProject(project, true);
projectElement.refresh();
} else if (delta.getKind() == IResourceDelta.REMOVED) {
- registry.remove(project);
+ TmfProjectElement projectElement = registry.remove(project);
+ if (projectElement != null) {
+ projectElement.dispose();
+ }
}
} catch (CoreException e) {
Activator.getDefault().logError("Error handling resource change event for " + project.getName(), e); //$NON-NLS-1$
@Override
public void dispose() {
+ super.dispose();
if (fChartViewer != null) {
fChartViewer.dispose();
}
*/
public abstract class TmfView extends ViewPart implements ITmfComponent {
+ private static final TmfAlignmentSynchronizer TIME_ALIGNMENT_SYNCHRONIZER = TmfAlignmentSynchronizer.getInstance();
private final String fName;
/** This allows us to keep track of the view sizes */
private Composite fParentComposite;
private ControlAdapter fControlListener;
- private static final TmfAlignmentSynchronizer TIME_ALIGNMENT_SYNCHRONIZER = new TmfAlignmentSynchronizer();
/**
* Action class for pinning of TmfView.