LTTng: Add unit tests for the virtual machine analysis
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Thu, 4 Dec 2014 02:46:32 +0000 (21:46 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Tue, 23 Dec 2014 15:53:14 +0000 (10:53 -0500)
Tests the virtual CPU state system and its integration with LTTng kernel
analysis.

Change-Id: I22467a6d6d502e60d87ee37322c4df83834f7575
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/37601
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.tracecompass.lttng2.kernel.core.tests/.classpath
org.eclipse.tracecompass.lttng2.kernel.core.tests/META-INF/MANIFEST.MF
org.eclipse.tracecompass.lttng2.kernel.core.tests/build.properties
org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTestExperiment.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTraces.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/AllTests.java
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/vm/AllTests.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/vm/VirtualMachineAnalysisTest.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.kernel.core.tests/testfiles/vm/OneQemuKvm/guest.xml [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.kernel.core.tests/testfiles/vm/OneQemuKvm/host.xml [new file with mode: 0644]

index 4f3836cfa98ad5fa92f7eca5ef12c779c1420dfc..8fbc9a2058ff20ae42178d66b0b5eb7154172dad 100644 (file)
@@ -4,5 +4,6 @@
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="perf"/>
+       <classpathentry kind="src" path="shared"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 4f7ad99a233717db81aa7c4997e91960039558d7..29b29a34e7f09967c5f4a8b0d516ab936551349c 100644 (file)
@@ -22,6 +22,7 @@ Export-Package: org.eclipse.tracecompass.lttng2.kernel.core.tests,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;x-internal:=true,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.event.matchandsync;x-internal:=true,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf,
- org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis;x-internal:=true
+ org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis;x-internal:=true,
+ org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm
 Import-Package: com.google.common.collect,
  org.eclipse.test.performance
index 74d42da1c609d2381cd2b89e877cda40f8b4a2c7..9f41c365bd524d8565cdba311a3eb27a55e5eceb 100644 (file)
@@ -11,7 +11,8 @@
 ###############################################################################
 
 source.. = src/,\
-           perf/
+           perf/,\
+           shared/
 output.. = bin/
 bin.includes = META-INF/,\
                .,\
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTestExperiment.java b/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTestExperiment.java
new file mode 100644 (file)
index 0000000..cad3099
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.trace.VirtualMachineExperiment;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+
+/**
+ * List virtual machine experiments that can be used in unit tests
+ *
+ * @author Geneviève Bastien
+ */
+public enum VmTestExperiment {
+
+    /**
+     * Virtual machine experiment: 1 guest, 1 host, using QEMU/KVM model
+     */
+    ONE_QEMUKVM(VmTraces.HOST_ONE_QEMUKVM, VmTraces.GUEST_ONE_QEMUKVM);
+
+    private Set<VmTraces> fTraces = new HashSet<>();
+
+    private VmTestExperiment(VmTraces... traces) {
+        for (VmTraces trace : traces) {
+            fTraces.add(trace);
+        }
+    }
+
+    /**
+     * Return a VirtualMachineExperiment object for this experiment with all its
+     * traces. It will be already initTrace()'ed.
+     *
+     * Make sure you call {@link #exists()} before calling this! This will make
+     * sure all traces in the experiment are available
+     *
+     * After being used by unit tests, the experiment must be properly disposed
+     * of by calling the {@link VirtualMachineExperiment#dispose()} method on
+     * the object returned by this method.
+     *
+     * @param deleteSuppFiles
+     *            Indicate whether to make sure supplementary files are deleted
+     * @return A VirtualMachineExperiment object corresponding to this
+     *         experiment
+     */
+    public synchronized VirtualMachineExperiment getExperiment(boolean deleteSuppFiles) {
+        Set<ITmfTrace> traces = new HashSet<>();
+        for (VmTraces trace : fTraces) {
+            traces.add(trace.getTrace());
+        }
+        @SuppressWarnings("null")
+        @NonNull String expName = this.name();
+        VirtualMachineExperiment experiment = new VirtualMachineExperiment(expName, traces);
+        if (deleteSuppFiles) {
+            /*
+             * Delete the supplementary files, so that the next iteration
+             * rebuilds the state system.
+             */
+            File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(experiment));
+            for (File file : suppDir.listFiles()) {
+                file.delete();
+            }
+        }
+        return experiment;
+    }
+
+    /**
+     * Check if all the traces actually exist on disk or not.
+     *
+     * @return If all traces for this experiment are present
+     */
+    public boolean exists() {
+        boolean exists = true;
+        for (VmTraces trace : fTraces) {
+            exists &= trace.exists();
+        }
+        return exists;
+    }
+
+}
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTraces.java b/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/vm/VmTraces.java
new file mode 100644 (file)
index 0000000..e464161
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.lttng2.kernel.core.tests.Activator;
+import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+
+/**
+ * List the available virtual machine host and guest traces
+ *
+ * @author Geneviève Bastien
+ */
+public enum VmTraces {
+
+    /** Host from simple QEMU/KVM experiment */
+    HOST_ONE_QEMUKVM("vm/OneQemuKvm/host.xml"),
+    /** Guest from simple QEMU/KVM experiment */
+    GUEST_ONE_QEMUKVM("vm/OneQemuKvm/guest.xml");
+
+    private static final @NonNull String filePath = "testfiles";
+
+    private final IPath fPath;
+
+    VmTraces(String path) {
+        IPath relativePath = new Path(filePath + File.separator + path);
+        Activator plugin = Activator.getDefault();
+        if (plugin == null) {
+            /*
+             * Shouldn't happen but at least throw something to get the test to
+             * fail early
+             */
+            throw new IllegalStateException();
+        }
+        URL location = FileLocator.find(plugin.getBundle(), relativePath, null);
+        try {
+            fPath = new Path(FileLocator.toFileURL(location).getPath());
+        } catch (IOException e) {
+            throw new IllegalStateException();
+        }
+    }
+
+    /**
+     * Return a TmfXmlTraceStub object of this test trace. It will be already
+     * initTrace()'ed.
+     *
+     * Make sure you call {@link #exists()} before calling this!
+     *
+     * @return A TmfXmlTraceStub reference to this trace
+     */
+    public ITmfTrace getTrace() {
+        ITmfTrace trace = new TmfXmlTraceStub();
+        IStatus status = trace.validate(null, fPath.toOSString());
+        if (!status.isOK()) {
+            return null;
+        }
+        try {
+            trace.initTrace(null, fPath.toOSString(), TmfEvent.class);
+        } catch (TmfTraceException e) {
+            return null;
+        }
+        return trace;
+    }
+
+    /**
+     * Check if the trace actually exists on disk or not.
+     *
+     * @return If the trace is present
+     */
+    public boolean exists() {
+        return fPath.toFile().exists();
+    }
+}
index 93d6a6b9cc95b001e349dea498e4fb778d9a2c0d..965aee70a6e2c010019f56703cf7f6fce5a9bcb0 100644 (file)
@@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
     org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.cpuusage.AllTests.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.AllTests.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem.TestAll.class,
+    org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.vm.AllTests.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.event.matchandsync.AllTests.class
 })
 public class AllTests {
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/vm/AllTests.java b/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/vm/AllTests.java
new file mode 100644 (file)
index 0000000..2223160
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.vm;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+        VirtualMachineAnalysisTest.class
+})
+public class AllTests {
+}
\ No newline at end of file
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/vm/VirtualMachineAnalysisTest.java b/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/analysis/vm/VirtualMachineAnalysisTest.java
new file mode 100644 (file)
index 0000000..089a7b0
--- /dev/null
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.vm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.VcpuStateValues;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.VmAttributes;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.module.VirtualMachineCpuAnalysis;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.trace.VirtualMachineExperiment;
+import org.eclipse.tracecompass.lttng2.kernel.core.analysis.kernel.LttngKernelAnalysis;
+import org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm.VmTestExperiment;
+import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
+import org.eclipse.tracecompass.statesystem.core.StateSystemUtils;
+import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
+import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
+import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
+import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
+import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
+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;
+
+import com.google.common.collect.Multimap;
+
+/**
+ * Test suite for the {@link VirtualMachineCpuAnalysis} class
+ *
+ * @author Geneviève Bastien
+ */
+public class VirtualMachineAnalysisTest {
+
+    private static void verifyStateIntervals(String testId, List<ITmfStateInterval> intervals, int[] expectedStarts, ITmfStateValue[] expectedValues) {
+        int expectedCount = expectedStarts.length - 1;
+
+        assertEquals(testId + ": Interval count", expectedCount, intervals.size());
+        for (int i = 0; i < expectedCount; i++) {
+            ITmfStateInterval interval = intervals.get(i);
+            assertEquals(testId + ": Start time of interval " + i, expectedStarts[i], interval.getStartTime());
+            long actualEnd = (i == expectedCount - 1) ? (expectedStarts[i + 1]) : (expectedStarts[i + 1]) - 1;
+            assertEquals(testId + ": End time of interval " + i, actualEnd, interval.getEndTime());
+            assertEquals(testId + ": Expected value of interval " + i, expectedValues[i], interval.getStateValue());
+        }
+    }
+
+    private static void verifyIntervalsWithMask(String testId, Collection<ITmfStateInterval> intervals, int[] expectedStarts, int[] expectedEnds, ITmfStateValue[] expectedValues, int mask) {
+        int expectedCount = expectedStarts.length - 1;
+
+        assertEquals(testId + ": Interval count", expectedCount, intervals.size());
+        int i = 0;
+        for (ITmfStateInterval interval : intervals) {
+            assertEquals(testId + ": Start time of interval " + i, expectedStarts[i], interval.getStartTime());
+            assertEquals(testId + ": End time of interval " + i, expectedEnds[i], interval.getEndTime());
+            assertEquals(testId + ": Expected value of interval " + i, expectedValues[i].unboxInt() & mask, interval.getStateValue().unboxInt() & mask);
+            i++;
+        }
+    }
+
+    /**
+     * Test the analysis execution with stub traces of a virtual machine with
+     * one virtual machine and one CPU
+     */
+    @Test
+    public void testStubTracesOneQemuKvm() {
+
+        assumeTrue(VmTestExperiment.ONE_QEMUKVM.exists());
+        VirtualMachineExperiment experiment = VmTestExperiment.ONE_QEMUKVM.getExperiment(true);
+
+        /* Open the traces */
+        for (ITmfTrace trace : experiment.getTraces()) {
+            ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
+        }
+
+        /*
+         * TODO For now, make sure the LttngKernelAnalysis have been run for
+         * each trace before running the analysis. When event request precedence
+         * is implemented, we can remove this
+         */
+        for (ITmfTrace trace : experiment.getTraces()) {
+            for (LttngKernelAnalysis module : TmfTraceUtils.getAnalysisModulesOfClass(trace, LttngKernelAnalysis.class)) {
+                module.schedule();
+                module.waitForCompletion();
+            }
+        }
+        /* End of TODO block */
+
+        experiment.traceOpened(new TmfTraceOpenedSignal(this, experiment, null));
+        VirtualMachineCpuAnalysis module = null;
+        for (VirtualMachineCpuAnalysis mod : TmfTraceUtils.getAnalysisModulesOfClass(experiment, VirtualMachineCpuAnalysis.class)) {
+            module = mod;
+            break;
+        }
+        assertNotNull(module);
+        module.schedule();
+        if (!module.waitForCompletion()) {
+            fail("Module did not complete properly");
+        }
+
+        try {
+            /* Check the state system */
+            ITmfStateSystem ss = module.getStateSystem();
+            assertNotNull(ss);
+            int vmQuark;
+
+            vmQuark = ss.getQuarkAbsolute(VmAttributes.VIRTUAL_MACHINES);
+
+            List<Integer> guestQuarks = ss.getSubAttributes(vmQuark, false);
+            assertEquals("Number of guests", 1, guestQuarks.size());
+            List<Integer> vcpuQuarks = ss.getSubAttributes(guestQuarks.get(0), false);
+            assertEquals("Number of virtual CPUs", 1, vcpuQuarks.size());
+            Integer statusQuark = ss.getQuarkRelative(vcpuQuarks.get(0), VmAttributes.STATUS);
+
+            /* Check the intervals for the virtual CPU */
+            List<ITmfStateInterval> intervals = StateSystemUtils.queryHistoryRange(ss, statusQuark, ss.getStartTime(), ss.getCurrentEndTime());
+
+            /* Expected interval values for the virtual CPU */
+            int[] expectedStarts = { 1, 60, 75, 95, 100, 150, 155, 195, 210, 245, 260, 295, 300, 350, 355, 375 };
+            ITmfStateValue[] expectedValues = { TmfStateValue.nullValue(),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_UNKNOWN),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING | VcpuStateValues.VCPU_VMM),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING | VcpuStateValues.VCPU_VMM | VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING | VcpuStateValues.VCPU_VMM),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING | VcpuStateValues.VCPU_VMM),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING | VcpuStateValues.VCPU_VMM),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING | VcpuStateValues.VCPU_VMM),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING | VcpuStateValues.VCPU_VMM | VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING | VcpuStateValues.VCPU_VMM),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING) };
+            verifyStateIntervals("Virtual CPU", intervals, expectedStarts, expectedValues);
+
+            /* Check the status of the guest's threads */
+            int[] expectedStartsT130 = { 10, 35, 75, 175, 195, 225, 275, 295, 300, 350, 375 };
+            int[] expectedEndsT130 = { 34, 74, 174, 224, 209, 274, 374, 299, 349, 354, 375 };
+            ITmfStateValue[] expectedValuesT30 = { TmfStateValue.newValueInt(VcpuStateValues.VCPU_IDLE),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_IDLE),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_IDLE),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING) };
+
+            int[] expectedStartsT131 = { 10, 35, 75, 95, 100, 150, 175, 225, 245, 275, 375 };
+            int[] expectedEndsT131 = { 34, 74, 174, 99, 149, 154, 224, 274, 259, 374, 375 };
+            ITmfStateValue[] expectedValuesT31 = { TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_IDLE),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_IDLE),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_PREEMPT),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_IDLE),
+                    TmfStateValue.newValueInt(VcpuStateValues.VCPU_RUNNING) };
+
+            Multimap<Integer, ITmfStateInterval> threadIntervals = module.getUpdatedThreadIntervals(guestQuarks.get(0), ss.getStartTime(), ss.getCurrentEndTime(), 1, new NullProgressMonitor());
+            verifyIntervalsWithMask("Thread 130", threadIntervals.get(130), expectedStartsT130, expectedEndsT130, expectedValuesT30, VcpuStateValues.VCPU_PREEMPT);
+            verifyIntervalsWithMask("Thread 131", threadIntervals.get(131), expectedStartsT131, expectedEndsT131, expectedValuesT31, VcpuStateValues.VCPU_PREEMPT);
+
+        } catch (AttributeNotFoundException | StateSystemDisposedException e) {
+            fail(e.getMessage());
+        } finally {
+            experiment.dispose();
+        }
+    }
+
+}
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core.tests/testfiles/vm/OneQemuKvm/guest.xml b/org.eclipse.tracecompass.lttng2.kernel.core.tests/testfiles/vm/OneQemuKvm/guest.xml
new file mode 100644 (file)
index 0000000..1075730
--- /dev/null
@@ -0,0 +1,105 @@
+<trace>
+<event timestamp="0" name="set_aspects">
+<field name="cpu" value="1" type="int" />
+</event>
+<event timestamp="10" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any" type="string" />
+<field name="prev_tid" value="130" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any2" type="string" />
+<field name="next_tid" value="131" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="35" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any2" type="string" />
+<field name="prev_tid" value="131" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any" type="string" />
+<field name="next_tid" value="130" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="40" name="vmsync_gh_guest">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="1" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="65" name="vmsync_hg_guest">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="2" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="75" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any" type="string" />
+<field name="prev_tid" value="130" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any2" type="string" />
+<field name="next_tid" value="131" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="175" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any2" type="string" />
+<field name="prev_tid" value="131" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any" type="string" />
+<field name="next_tid" value="130" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="190" name="vmsync_gh_guest">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="3" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="215" name="vmsync_hg_guest">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="4" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="225" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any" type="string" />
+<field name="prev_tid" value="130" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any2" type="string" />
+<field name="next_tid" value="131" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="240" name="vmsync_gh_guest">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="5" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="265" name="vmsync_hg_guest">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="6" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="275" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any2" type="string" />
+<field name="prev_tid" value="131" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any" type="string" />
+<field name="next_tid" value="130" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="375" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any" type="string" />
+<field name="prev_tid" value="130" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any2" type="string" />
+<field name="next_tid" value="131" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+</trace>
\ No newline at end of file
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core.tests/testfiles/vm/OneQemuKvm/host.xml b/org.eclipse.tracecompass.lttng2.kernel.core.tests/testfiles/vm/OneQemuKvm/host.xml
new file mode 100644 (file)
index 0000000..97db30f
--- /dev/null
@@ -0,0 +1,149 @@
+<trace>
+<event timestamp="0" name="set_aspects">
+<field name="cpu" value="1" type="int" />
+</event>
+<event timestamp="1" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any" type="string" />
+<field name="prev_tid" value="30" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="qemucpu1" type="string" />
+<field name="next_tid" value="31" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="5" name="kvm_entry">
+<field name="cpu" value="0" type="int" />
+<field name="vcpu_id" value="0" type="long" />
+</event>
+<event timestamp="45" name="kvm_exit">
+<field name="cpu" value="0" type="int" />
+<field name="exit_reason" value="32" type="int" />
+<field name="guest_rip" value="123456" type="long" />
+<field name="isa" value="1" type="int" />
+<field name="info1" value="654654" type="long" />
+<field name="info2" value="456789" type="long" />
+</event>
+<event timestamp="50" name="vmsync_gh_host">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="1" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="55" name="vmsync_hg_host">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="2" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="60" name="kvm_entry">
+<field name="cpu" value="0" type="int" />
+<field name="vcpu_id" value="0" type="long" />
+</event>
+<event timestamp="95" name="kvm_exit">
+<field name="cpu" value="0" type="int" />
+<field name="exit_reason" value="32" type="int" />
+<field name="guest_rip" value="123456" type="long" />
+<field name="isa" value="1" type="int" />
+<field name="info1" value="654654" type="long" />
+<field name="info2" value="456789" type="long" />
+</event>
+<event timestamp="100" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="qemucpu1" type="string" />
+<field name="prev_tid" value="31" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any" type="string" />
+<field name="next_tid" value="30" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="150" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any" type="string" />
+<field name="prev_tid" value="30" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="qemucpu1" type="string" />
+<field name="next_tid" value="31" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="155" name="kvm_entry">
+<field name="cpu" value="0" type="int" />
+<field name="vcpu_id" value="0" type="long" />
+</event>
+<event timestamp="195" name="kvm_exit">
+<field name="cpu" value="0" type="int" />
+<field name="exit_reason" value="32" type="int" />
+<field name="guest_rip" value="123456" type="long" />
+<field name="isa" value="1" type="int" />
+<field name="info1" value="654654" type="long" />
+<field name="info2" value="456789" type="long" />
+</event>
+<event timestamp="200" name="vmsync_gh_host">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="3" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="205" name="vmsync_hg_host">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="4" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="210" name="kvm_entry">
+<field name="cpu" value="0" type="int" />
+<field name="vcpu_id" value="0" type="long" />
+</event>
+<event timestamp="245" name="kvm_exit">
+<field name="cpu" value="0" type="int" />
+<field name="exit_reason" value="32" type="int" />
+<field name="guest_rip" value="123456" type="long" />
+<field name="isa" value="1" type="int" />
+<field name="info1" value="654654" type="long" />
+<field name="info2" value="456789" type="long" />
+</event>
+<event timestamp="250" name="vmsync_gh_host">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="5" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="255" name="vmsync_hg_host">
+<field name="cpu" value="0" type="int" />
+<field name="cnt" value="6" type="int" />
+<field name="vm_uid" value="123456" type="long" />
+</event>
+<event timestamp="260" name="kvm_entry">
+<field name="cpu" value="0" type="int" />
+<field name="vcpu_id" value="0" type="long" />
+</event>
+<event timestamp="295" name="kvm_exit">
+<field name="cpu" value="0" type="int" />
+<field name="exit_reason" value="32" type="int" />
+<field name="guest_rip" value="123456" type="long" />
+<field name="isa" value="1" type="int" />
+<field name="info1" value="654654" type="long" />
+<field name="info2" value="456789" type="long" />
+</event>
+<event timestamp="300" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="qemucpu1" type="string" />
+<field name="prev_tid" value="31" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="any" type="string" />
+<field name="next_tid" value="30" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="350" name="sched_switch">
+<field name="cpu" value="0" type="int" />
+<field name="prev_comm" value="any" type="string" />
+<field name="prev_tid" value="30" type="long" />
+<field name="prev_prio" value="20" type="int" />
+<field name="prev_state" value="0" type="long" />
+<field name="next_comm" value="qemucpu1" type="string" />
+<field name="next_tid" value="31" type="long" />
+<field name="next_prio" value="20" type="int" />
+</event>
+<event timestamp="355" name="kvm_entry">
+<field name="cpu" value="0" type="int" />
+<field name="vcpu_id" value="0" type="long" />
+</event>
+</trace>
\ No newline at end of file
This page took 0.047935 seconds and 5 git commands to generate.