use of org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace in project tracecompass by tracecompass.
the class StreamListAnalysisTest method executeAnalysisTest.
/**
* Method that execute the analysis and verify the results.
*
* @throws TmfAnalysisException
* Thrown when an analysis error occurs during the setup or
* execution. Fails the test.
* @throws TmfTraceException
* Thrown when the trace cannot be initialized. Fails the test.
*/
@Test
public void executeAnalysisTest() throws TmfAnalysisException, TmfTraceException {
PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP;
assumeTrue(trace.exists());
String path = trace.getPath().toString();
PcapTrace pcapTrace = new PcapTrace();
StreamListAnalysis analysis = new StreamListAnalysis();
pcapTrace.initTrace(null, path, null);
analysis.setId(StreamListAnalysis.ID);
analysis.setTrace(pcapTrace);
analysis.schedule();
analysis.waitForCompletion();
// Verify that builders are not empty.
TmfPacketStreamBuilder builder = analysis.getBuilder(TmfPcapProtocol.ETHERNET_II);
if (builder == null) {
fail("The PacketStreamBuilder is null!");
return;
}
assertEquals(1, builder.getNbStreams());
builder = analysis.getBuilder(TmfPcapProtocol.IPV4);
if (builder == null) {
fail("The PacketStreamBuilder is null!");
return;
}
assertEquals(3, builder.getNbStreams());
builder = analysis.getBuilder(TmfPcapProtocol.TCP);
if (builder == null) {
fail("The PacketStreamBuilder is null!");
return;
}
assertEquals(2, builder.getNbStreams());
builder = analysis.getBuilder(TmfPcapProtocol.UDP);
if (builder == null) {
fail("The PacketStreamBuilder is null!");
return;
}
assertEquals(1, builder.getNbStreams());
analysis.dispose();
pcapTrace.dispose();
}
use of org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace in project tracecompass by tracecompass.
the class StreamListAnalysisTest method canExecuteTest.
/**
* Method that tests canExecute().
*
* @throws TmfTraceException
* Thrown when the trace cannot be initialized. Fails the test.
*/
@Test
public void canExecuteTest() throws TmfTraceException {
PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP;
assumeTrue(trace.exists());
String path = trace.getPath().toString();
PcapTrace pcapTrace = new PcapTrace();
StreamListAnalysis analysis = new StreamListAnalysis();
analysis.setId(StreamListAnalysis.ID);
pcapTrace.initTrace(null, path, null);
assertTrue(analysis.canExecute(pcapTrace));
analysis.dispose();
pcapTrace.dispose();
}
use of org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace in project tracecompass by tracecompass.
the class PcapTraceTest method testPcapTrace.
/**
* Run the PcapTrace() constructor test.
*/
@Test
public void testPcapTrace() {
PcapTrace result = new PcapTrace();
assertNotNull(result);
assertEquals(1000, result.getCacheSize());
assertEquals(0L, result.getNbEvents());
assertEquals(0L, result.getStreamingInterval());
assertNull(result.getResource());
assertNull(result.getEventType());
result.dispose();
}
use of org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace in project tracecompass by tracecompass.
the class ImportAndReadPcapTest method getEvent.
private static ITmfEvent getEvent(int rank) {
PcapTrace trace = pttt.getTrace();
ITmfContext ctx = trace.seekEvent(0);
for (int i = 0; i < rank; i++) {
trace.getNext(ctx);
}
ITmfEvent ret = trace.getNext(ctx);
trace.dispose();
return ret;
}
use of org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace in project tracecompass by tracecompass.
the class StreamListAnalysis method canExecute.
@Override
public boolean canExecute(ITmfTrace trace) {
// Trace is Pcap
if (trace instanceof PcapTrace) {
return true;
}
// Trace is not a TmfExperiment
if (!(trace instanceof TmfExperiment)) {
return false;
}
// Trace is TmfExperiment. Check if it has a PcapTrace.
TmfExperiment experiment = (TmfExperiment) trace;
List<ITmfTrace> traces = experiment.getTraces();
for (ITmfTrace expTrace : traces) {
if (expTrace instanceof PcapTrace) {
return true;
}
}
// No Pcap :(
return false;
}
Aggregations