1 /*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.lttng2
.lttng
.kernel
.core
.tests
.shared
.vm
;
16 import java
.util
.HashSet
;
19 import org
.eclipse
.jdt
.annotation
.NonNull
;
20 import org
.eclipse
.tracecompass
.internal
.lttng2
.kernel
.core
.analysis
.vm
.trace
.VirtualMachineExperiment
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.experiment
.TmfExperiment
;
26 * List virtual machine experiments that can be used in unit tests
28 * @author Geneviève Bastien
30 public enum VmTestExperiment
{
33 * Virtual machine experiment: 1 guest, 1 host, using QEMU/KVM model
35 ONE_QEMUKVM(VmTraces
.HOST_ONE_QEMUKVM
, VmTraces
.GUEST_ONE_QEMUKVM
);
37 private Set
<VmTraces
> fTraces
= new HashSet
<>();
39 private VmTestExperiment(VmTraces
... traces
) {
40 for (VmTraces trace
: traces
) {
46 * Return a VirtualMachineExperiment object for this experiment with all its
47 * traces. It will be already initTrace()'ed.
49 * Make sure you call {@link #exists()} before calling this! This will make
50 * sure all traces in the experiment are available
52 * After being used by unit tests, the experiment must be properly disposed
53 * of by calling the {@link VirtualMachineExperiment#dispose()} method on
54 * the object returned by this method.
56 * @param deleteSuppFiles
57 * Indicate whether to make sure supplementary files are deleted
58 * @return A VirtualMachineExperiment object corresponding to this
61 public synchronized TmfExperiment
getExperiment(boolean deleteSuppFiles
) {
62 Set
<ITmfTrace
> traces
= new HashSet
<>();
63 for (VmTraces trace
: fTraces
) {
64 traces
.add(trace
.getTrace());
66 @SuppressWarnings("null")
67 @NonNull String expName
= this.name();
68 VirtualMachineExperiment experiment
= new VirtualMachineExperiment(expName
, traces
);
69 if (deleteSuppFiles
) {
71 * Delete the supplementary files, so that the next iteration
72 * rebuilds the state system.
74 File suppDir
= new File(TmfTraceManager
.getSupplementaryFileDir(experiment
));
75 for (File file
: suppDir
.listFiles()) {
83 * Check if all the traces actually exist on disk or not.
85 * @return If all traces for this experiment are present
87 public boolean exists() {
88 boolean exists
= true;
89 for (VmTraces trace
: fTraces
) {
90 exists
&= trace
.exists();