use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.
the class UstKernelSyncTest method testOneEvent.
/**
* Test that the TID given by the kernel analysis matches the one from the
* UST event's context for a given UST event that was known to fail.
*
* Reproduces the specific example that was pointed out in bug 484620.
*/
@Test
public void testOneEvent() {
TmfExperiment experiment = fExperiment;
ITmfTrace ustTrace = fUstTrace;
KernelAnalysisModule module = fKernelModule;
assertNotNull(experiment);
assertNotNull(ustTrace);
assertNotNull(module);
Predicate<@NonNull ITmfEvent> eventFinder = event -> {
Long addr = event.getContent().getFieldValue(Long.class, "addr");
Long cs = event.getContent().getFieldValue(Long.class, "call_site");
Long ctxVtid = event.getContent().getFieldValue(Long.class, "context._vtid");
if (addr == null || cs == null || ctxVtid == null) {
return false;
}
return Objects.equals(event.getType().getName(), "lttng_ust_cyg_profile:func_entry") && Objects.equals(Long.toHexString(addr), "804af97") && Objects.equals(Long.toHexString(cs), "804ab03") && Objects.equals(ctxVtid.longValue(), 594L);
};
/* The event we're looking for is the second event matching the predicate */
CtfTmfEvent ustEvent = (CtfTmfEvent) TmfTraceUtils.getNextEventMatching(experiment, 0, eventFinder, null);
assertNotNull(ustEvent);
long rank = experiment.seekEvent(ustEvent.getTimestamp()).getRank() + 1;
ustEvent = (CtfTmfEvent) TmfTraceUtils.getNextEventMatching(experiment, rank, eventFinder, null);
assertNotNull(ustEvent);
/* Make sure the correct event was retrieved */
assertEquals(ustTrace, ustEvent.getTrace());
assertEquals(1450193715128075054L, ustEvent.getTimestamp().toNanos());
Integer tidFromKernel = KernelThreadInformationProvider.getThreadOnCpu(module, ustEvent.getCPU(), ustEvent.getTimestamp().toNanos());
assertNotNull(tidFromKernel);
assertEquals(594, tidFromKernel.intValue());
}
use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.
the class XmlDataProviderManagerTest method testExperimentWithTraceAnalysis.
/**
* Test getting the XML data provider for an experiment, with an analysis that
* applies to a trace
*/
@Test
public void testExperimentWithTraceAnalysis() {
ITmfTrace trace = null;
ITmfTrace trace2 = null;
ITmfTrace experiment = null;
try {
// Initialize the trace and module
trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
trace2 = XmlUtilsTest.initializeTrace(TEST_TRACE2);
ITmfTrace[] traces = { trace, trace2 };
experiment = new TmfExperiment(ITmfEvent.class, "Xml Experiment", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, experiment, null);
((TmfTrace) trace).traceOpened(signal);
((TmfTrace) trace2).traceOpened(signal);
((TmfTrace) experiment).traceOpened(signal);
// The data provider manager uses opened traces from the manager
TmfTraceManager.getInstance().traceOpened(signal);
Iterable<@NonNull DataDrivenAnalysisModule> modules = TmfTraceUtils.getAnalysisModulesOfClass(experiment, DataDrivenAnalysisModule.class);
modules.forEach(module -> {
module.schedule();
assertTrue(module.waitForCompletion());
});
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
assertNotNull(viewElement);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(experiment, viewElement);
assertNotNull(timeGraphProvider);
assertTrue(timeGraphProvider instanceof TmfTimeGraphCompositeDataProvider);
} finally {
if (trace != null) {
trace.dispose();
}
if (trace2 != null) {
trace2.dispose();
}
if (experiment != null) {
experiment.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, experiment));
}
}
}
use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.
the class SymbolProviderManagerTest method testGetterForExperiment.
/**
* Test the {@link SymbolProviderManager#getSymbolProviders(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)} for an experiment
*/
@Test
public void testGetterForExperiment() {
ITmfTrace trace = null;
TmfExperiment experiment = null;
try {
trace = TmfTestTrace.A_TEST_10K.getTrace();
ITmfTrace[] traces = new ITmfTrace[] { trace };
experiment = new TmfExperiment(ITmfEvent.class, "test-exp", traces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
// Get the symbol providers for the trace
Collection<ISymbolProvider> traceSymbolProviders = SymbolProviderManager.getInstance().getSymbolProviders(trace);
assertTrue(!traceSymbolProviders.isEmpty());
// Get the symbol providers for the experiment
Collection<ISymbolProvider> expSymbolProviders = SymbolProviderManager.getInstance().getSymbolProviders(experiment);
assertTrue(!expSymbolProviders.isEmpty());
// Assert that the trace of the symbol provider is the same
for (ISymbolProvider sp : expSymbolProviders) {
assertTrue(sp.getTrace() == trace);
}
for (ISymbolProvider symbolProvider : traceSymbolProviders) {
assertTrue(expSymbolProviders.contains(symbolProvider));
}
} finally {
if (trace != null) {
trace.dispose();
}
if (experiment != null) {
experiment.dispose();
}
}
}
use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.
the class TmfExperimentTest method testSimpleTmfExperimentConstructor.
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
@Test
public void testSimpleTmfExperimentConstructor() {
TmfExperiment experiment = new TmfExperiment(ITmfEvent.class, EXPERIMENT, fTestTraces, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
assertEquals("GetId", EXPERIMENT, experiment.getName());
assertEquals("GetCacheSize", TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, experiment.getCacheSize());
experiment.dispose();
experiment = new TmfExperiment(ITmfEvent.class, EXPERIMENT, null, TmfExperiment.DEFAULT_INDEX_PAGE_SIZE, null);
experiment.dispose();
}
use of org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment in project tracecompass by tracecompass.
the class TmfExperimentTest method testWithSingleHostClockOffset.
/**
* Tests that experiment with traces from the same host and a clock offset
* are well synchronized
*/
@Test
public void testWithSingleHostClockOffset() {
// Data for this specific test
String hostId = "Test Host 1";
long minOffset = 2000;
long offset = 1000;
String clockOffset = "clock_offset";
ITmfTrace t1 = new TestTrace("t1") {
@Override
@NonNull
public String getHostId() {
return hostId;
}
@Override
@NonNull
public Map<@NonNull String, @NonNull String> getProperties() {
return ImmutableMap.of(clockOffset, String.valueOf(minOffset));
}
};
ITmfTrace t2 = new TestTrace("t2") {
@Override
@NonNull
public String getHostId() {
return hostId;
}
@Override
@NonNull
public Map<@NonNull String, @NonNull String> getProperties() {
return ImmutableMap.of(clockOffset, String.valueOf(minOffset + offset));
}
};
TmfExperiment exp = new TmfExperimentStub(EXPERIMENT, new ITmfTrace[] { t1, t2 }, BLOCK_SIZE);
try {
assertEquals(TimestampTransformFactory.createWithOffset(offset / 2), t1.getTimestampTransform());
assertEquals(TimestampTransformFactory.createWithOffset(-offset / 2), t2.getTimestampTransform());
} finally {
exp.dispose();
}
}
Aggregations