Search in sources :

Example 1 with PcapTrace

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();
}
Also used : PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) TmfPacketStreamBuilder(org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis) PcapTestTrace(org.eclipse.tracecompass.pcap.core.tests.shared.PcapTestTrace) Test(org.junit.Test)

Example 2 with PcapTrace

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();
}
Also used : PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis) PcapTestTrace(org.eclipse.tracecompass.pcap.core.tests.shared.PcapTestTrace) Test(org.junit.Test)

Example 3 with PcapTrace

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();
}
Also used : PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) Test(org.junit.Test)

Example 4 with PcapTrace

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;
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)

Example 5 with PcapTrace

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;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)

Aggregations

PcapTrace (org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace)8 Test (org.junit.Test)4 PcapTestTrace (org.eclipse.tracecompass.pcap.core.tests.shared.PcapTestTrace)3 StreamListAnalysis (org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis)2 ArrayList (java.util.ArrayList)1 TmfPacketStreamBuilder (org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder)1 TmfPcapProtocol (org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol)1 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)1 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 TmfContext (org.eclipse.tracecompass.tmf.core.trace.TmfContext)1 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)1 TmfLongLocation (org.eclipse.tracecompass.tmf.core.trace.location.TmfLongLocation)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1