Merge commit 'cea87c3123c41bd06cd2b816f885a27612dfc356' into lttng-luna
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 18 Nov 2013 23:18:15 +0000 (18:18 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 18 Nov 2013 23:18:15 +0000 (18:18 -0500)
Conflicts:
lttng/org.eclipse.linuxtools.ctf.core.tests/pom.xml
lttng/org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTrace.java
lttng/org.eclipse.linuxtools.ctf.core.tests/traces/.gitignore
lttng/org.eclipse.linuxtools.ctf.core.tests/traces/get-traces.xml
lttng/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTrace.java

Change-Id: Id7e995409cfeace1407abea1bd7c3c81f758ef22

1  2 
org.eclipse.linuxtools.ctf.core.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.ctf.core.tests/pom.xml
org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTrace.java
org.eclipse.linuxtools.ctf.core.tests/traces/.gitignore
org.eclipse.linuxtools.ctf.core.tests/traces/get-traces.xml
org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTrace.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/FunkyTraceTest.java

index 831d5a7a9a559d39d103ee9e16282a69f6f6d04a,4537d74df1d8e800af962b03fdcec07583d3483d..51ebba5192fd7dbb2c39bcd46ab73fdb5b058ed8
@@@ -88,7 -88,7 +88,8 @@@
                    </excludes>
                  </fileset>
                  <fileset><directory>traces/ctf-testsuite</directory></fileset>
 +                <fileset><directory>traces/cyg-profile</directory></fileset>
+                 <fileset><directory>traces/funky_trace</directory></fileset>
                  <fileset><directory>traces/hello-lost</directory></fileset>
                  <fileset><directory>traces/kernel</directory></fileset>
                  <fileset><directory>traces/kernel_vm</directory></fileset>
index 300ee0262e0341cf5b2609b55cf4efb8cda52014,8a169c41362cf4bee2a9b4d5ac8644865f7f9c15..190270c5c267b8e2afa19641449740071a8208a8
@@@ -27,27 -28,16 +28,33 @@@ import org.eclipse.linuxtools.ctf.core.
  public enum CtfTestTrace {
      /** Example kernel trace */
      KERNEL("../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"),
 +
      /** Another kernel trace */
      TRACE2("../org.eclipse.linuxtools.ctf.core.tests/traces/trace2"),
 +
      /** Kernel trace with event contexts */
      KERNEL_VM("../org.eclipse.linuxtools.ctf.core.tests/traces/kernel_vm"),
 +
 +    /** Trace synchronization: source trace */
 +    SYNC_SRC("../org.eclipse.linuxtools.ctf.core.tests/traces/synctraces/scp_src"),
 +
 +    /** Trace synchronization: destination trace */
 +    SYNC_DEST("../org.eclipse.linuxtools.ctf.core.tests/traces/synctraces/scp_dest"),
 +
      /** UST trace with lots of lost events */
      HELLO_LOST("../org.eclipse.linuxtools.ctf.core.tests/traces/hello-lost"),
-     CYG_PROFILE_FAST("../org.eclipse.linuxtools.ctf.core.tests/traces/cyg-profile/glxgears-cyg-profile-fast");
 +
 +    /** UST trace with lttng-ust-cyg-profile events (aka -finstrument-functions) */
 +    CYG_PROFILE("../org.eclipse.linuxtools.ctf.core.tests/traces/cyg-profile/glxgears-cyg-profile"),
 +
 +    /** UST trace with lttng-ust-cyg-profile-fast events (no address in func_exit) */
++    CYG_PROFILE_FAST("../org.eclipse.linuxtools.ctf.core.tests/traces/cyg-profile/glxgears-cyg-profile-fast"),
++
+     /** Autogenerated Syntetic trace */
+     SYNTHETIC_TRACE(LttngKernelTraceGenerator.getPath()),
++
+     /** Trace with non-standard field sizes */
+     FUNKY_TRACE("../org.eclipse.linuxtools.ctf.core.tests/traces/funky_trace");
  
  
      private final String fPath;
index 3f6d15926fecb8821daf1d843843cc935924bcf3,dc5ab29919115964035fe3334f1e0517ad314e4c..8c38765e662657c68d680f904908311fd0102021
@@@ -1,9 -1,7 +1,10 @@@
  *.bz2
 +*.gz
  *.tar
 +*.ht
  /ctf-testsuite
 +/cyg-profile
+ /funky_trace
  /hello-lost
  /kernel
  /kernel_vm
index f7e52bd02398fcf940239fce09095e1edb38dca9,52ed627645ecf1e16a1a1483beb29aad5d1fdab7..298b98aacf3bfe637e23f6990e888f85c6c1a61d
    <get ignoreerrors="true" dest="sample-ctf-trace-20120412.tar.bz2" skipexisting="true" src="http://lttng.org/files/samples/sample-ctf-trace-20120412.tar.bz2"/>
    <get ignoreerrors="true" dest="trace2.tar.bz2" skipexisting="true" src="http://www.dorsal.polymtl.ca/~alexmont/data/trace2.tar.bz2"/>
    <get ignoreerrors="true" dest="kernel_vm.tar.bz2" skipexisting="true" src="http://www.dorsal.polymtl.ca/~alexmont/data/kernel_vm.tar.bz2" />
 +  <get ignoreerrors="true" dest="synctraces.tar.gz" skipexisting="true" src="http://www.dorsal.polymtl.ca/~gbastien/traces/synctraces.tar.gz" />
    <get ignoreerrors="true" dest="hello-lost.tar.bz2" skipexisting="true" src="http://www.dorsal.polymtl.ca/~alexmont/data/hello-lost.tar.bz2" />
 +  <get ignoreerrors="true" dest="cyg-profile.tar.bz2" skipexisting="true" src="http://www.dorsal.polymtl.ca/~alexmont/data/cyg-profile.tar.bz2" />
+   <get ignoreerrors="true" dest="funky_trace.tar.bz2" skipexisting="true" src="http://www.dorsal.polymtl.ca/~alexmont/data/funky_trace.tar.bz2" />
    <exec executable = "git" failifexecutionfails="false">
      <arg value = "clone"/>
      <arg value = "https://github.com/efficios/ctf-testsuite.git"/>
        <available file="sample-ctf-trace-20120412.tar.bz2"/>
        <available file="trace2.tar.bz2"/>
        <available file="kernel_vm.tar.bz2" />
 +      <available file="synctraces.tar.gz" />
        <available file="hello-lost.tar.bz2" />
 +      <available file="cyg-profile.tar.bz2" />
+       <available file="funky_trace.tar.bz2" />
      </and>
    </condition>
    <antcall target="extractTraces"/>
      <bunzip2 src="sample-ctf-trace-20120412.tar.bz2"/>
      <bunzip2 src="trace2.tar.bz2"/>
      <bunzip2 src="kernel_vm.tar.bz2" />
 +    <gunzip src="synctraces.tar.gz" />
      <bunzip2 src="hello-lost.tar.bz2" />
 +    <bunzip2 src="cyg-profile.tar.bz2" />
+     <bunzip2 src="funky_trace.tar.bz2" />
  
      <untar src="sample-ctf-trace-20120412.tar" dest="." />
      <untar src="trace2.tar" dest="." />
      <untar src="kernel_vm.tar" dest="." />
 +    <untar src="synctraces.tar" dest="." />
      <untar src="hello-lost.tar" dest="." />
 +    <untar src="cyg-profile.tar" dest="." />
+     <untar src="funky_trace.tar" dest="." />
 +
      <echo message="Traces extracted successfully"/>
  </target>
  </project>
index 2d0f84ac4b25c87ff693ee50d32b6e7b1614e1e8,e9c07f42289bccad65b471c7908fa3f5ddbd4016..b7404783ab0030fc17359e420af8875d407d5824
@@@ -33,16 -32,12 +33,20 @@@ public enum CtfTmfTestTrace 
      TRACE2,
      /** Kernel trace with event contexts */
      KERNEL_VM,
 +    /** Trace synchronization: source trace */
 +    SYNC_SRC,
 +    /** Trace synchronization: destination trace */
 +    SYNC_DEST,
      /** UST trace with lots of lost events */
      HELLO_LOST,
-     CYG_PROFILE_FAST;
 +    /** UST trace with lttng-ust-cyg-profile events (aka -finstrument-functions) */
 +    CYG_PROFILE,
 +    /** UST trace with lttng-ust-cyg-profile-fast events (no address in func_exit) */
++    CYG_PROFILE_FAST,
+     /** Autogenerated Syntetic trace */
+     SYNTHETIC_TRACE,
+     /** Trace with non-standard field sizes */
+     FUNKY_TRACE;
  
  
      private final String fPath;
index 0000000000000000000000000000000000000000,415585bb40adbb250db353b5d919ae76050b1740..58ffa7333e2086322364a41e2c0f4438239d9930
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,204 +1,203 @@@
 -                    1,
+ /*******************************************************************************
+  * Copyright (c) 2013 Ericsson
+  *
+  * All rights reserved. This program and the accompanying materials are
+  * made available under the terms of the Eclipse Public License v1.0 which
+  * accompanies this distribution, and is available at
+  * http://www.eclipse.org/legal/epl-v10.html
+  *
+  * Contributors:
+  *   Alexandre Montplaisir - Initial API and implementation
+  *******************************************************************************/
+ package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
+ import static org.junit.Assert.assertArrayEquals;
+ import static org.junit.Assert.assertEquals;
+ import static org.junit.Assume.assumeTrue;
+ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfEnumPair;
+ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
+ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
+ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+ import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
+ import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+ import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
+ import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+ import org.junit.AfterClass;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+ /**
+  * More advanced CTF tests using "funky_trace", a trace generated with the
+  * Babeltrace CTF writer API, which has lots of fun things like different
+  * integer/float sizes and non-standard struct alignments.
+  *
+  * @author Alexandre Montplaisir
+  */
+ public class FunkyTraceTest {
+     // ------------------------------------------------------------------------
+     // Attributes
+     // ------------------------------------------------------------------------
+     private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.FUNKY_TRACE;
+     private static final double DELTA = 0.0000001;
+     private static CtfTmfTrace fTrace;
+     // ------------------------------------------------------------------------
+     // Setup
+     // ------------------------------------------------------------------------
+     /**
+      * Test setup
+      */
+     @BeforeClass
+     public static void setupClass() {
+         assumeTrue(testTrace.exists());
+         fTrace = testTrace.getTrace();
+         fTrace.indexTrace(true);
+     }
+     /**
+      * Clean-up
+      */
+     @AfterClass
+     public static void tearDownClass() {
+         fTrace.dispose();
+     }
+     // ------------------------------------------------------------------------
+     // Test methods
+     // ------------------------------------------------------------------------
+     /**
+      * Verify the contents of the first event
+      */
+     @Test
+     public void testFirstEvent() {
+         CtfTmfEvent event = getEvent(0);
+         assertEquals("Simple Event", event.getEventName());
+         assertEquals(1234567, event.getTimestamp().getValue());
+         assertEquals(42, ((Long) event.getContent().getField("integer_field").getValue()).intValue());
+         assertEquals(3.1415, ((Double) event.getContent().getField("float_field").getValue()).doubleValue(), DELTA);
+     }
+     /**
+      * Verify the contents of the second event (the first "spammy event")
+      */
+     @Test
+     public void testSecondEvent() {
+         CtfTmfEvent event = getEvent(1);
+         assertEquals("Spammy_Event", event.getEventName());
+         assertEquals(1234568, event.getTimestamp().getValue());
+         assertEquals(0, ((Long) event.getContent().getField("field_1").getValue()).intValue());
+         assertEquals("This is a test", event.getContent().getField("a_string").getValue());
+     }
+     /**
+      * Verify the contents of the last "spammy event"
+      */
+     @Test
+     public void testSecondToLastEvent() {
+         CtfTmfEvent event = getEvent(100000);
+         assertEquals("Spammy_Event", event.getEventName());
+         assertEquals(1334567, event.getTimestamp().getValue());
+         assertEquals(99999, ((Long) event.getContent().getField("field_1").getValue()).intValue());
+         assertEquals("This is a test", event.getContent().getField("a_string").getValue());
+     }
+     /**
+      * Verify the contents of the last, complex event
+      */
+     @Test
+     public void testLastEvent() {
+         /*
+          * Last event as seen in Babeltrace:
+          * [19:00:00.001334568] (+0.000000001) Complex Test Event: { }, {
+          *     uint_35 = 0xDDF00D,
+          *     int_16 = -12345,
+          *     complex_structure = {
+          *         variant_selector = ( INT16_TYPE : container = 1 ),
+          *         a_string = "Test string",
+          *         variant_value = { INT16_TYPE = -200 },
+          *         inner_structure = {
+          *             seq_len = 0xA,
+          *             a_sequence = [ [0] = 4, [1] = 3, [2] = 2, [3] = 1, [4] = 0, [5] = -1, [6] = -2, [7] = -3, [8] = -4, [9] = -5 ]
+          *         }
+          *     }
+          * }
+          */
+         CtfTmfEvent event = getEvent(100001);
+         assertEquals("Complex Test Event", event.getEventName());
+         assertEquals(1334568, event.getTimestamp().getValue());
+         assertEquals(0xddf00d, ((Long) event.getContent().getField("uint_35").getValue()).intValue());
+         assertEquals(-12345, ((Long) event.getContent().getField("int_16").getValue()).intValue());
+         ITmfEventField[] complexStruct =
+                 (ITmfEventField[]) event.getContent().getField("complex_structure").getValue();
+         assertEquals("variant_selector", complexStruct[0].getName());
+         CtfEnumPair variant1 = (CtfEnumPair) complexStruct[0].getValue();
+         assertEquals("INT16_TYPE", variant1.getStringValue());
+         assertEquals(Long.valueOf(1), variant1.getLongValue());
+         assertEquals("a_string", complexStruct[1].getName());
+         assertEquals("Test string", complexStruct[1].getValue());
+         assertEquals("variant_value", complexStruct[2].getName());
+         ITmfEventField variantField = (ITmfEventField) complexStruct[2].getValue();
+         assertEquals("INT16_TYPE", variantField.getName());
+         assertEquals(Long.valueOf(-200), variantField.getValue());
+         ITmfEventField[] innerStruct = (ITmfEventField[]) complexStruct[3].getValue();
+         assertEquals("seq_len", innerStruct[0].getName());
+         assertEquals(Long.valueOf(10), innerStruct[0].getValue());
+         assertEquals("a_sequence", innerStruct[1].getName());
+         long[] seqValues = (long[]) innerStruct[1].getValue();
+         long[] expectedValues = { 4, 3, 2, 1, 0, -1, -2, -3, -4, -5 };
+         assertArrayEquals(expectedValues, seqValues);
+     }
+     // ------------------------------------------------------------------------
+     // Private stuff
+     // ------------------------------------------------------------------------
+     private synchronized CtfTmfEvent getEvent(long index) {
+         TestEventRequest req = new TestEventRequest(index);
+         fTrace.sendRequest(req);
+         try {
+             req.waitForCompletion();
+         } catch (InterruptedException e) {
+             return null;
+         }
+         return req.getEvent();
+     }
+     private class TestEventRequest extends TmfEventRequest {
+         private CtfTmfEvent fRetEvent = null;
+         public TestEventRequest(long index) {
+             super(CtfTmfEvent.class,
+                     TmfTimeRange.ETERNITY,
+                     index,
+                     1,
+                     ExecutionType.FOREGROUND);
+         }
+         @Override
+         public void handleData(ITmfEvent event) {
+             fRetEvent = (CtfTmfEvent) event;
+         }
+         public CtfTmfEvent getEvent() {
+             return fRetEvent;
+         }
+     }
+ }
This page took 0.031762 seconds and 5 git commands to generate.