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
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
18 import java
.util
.HashSet
;
21 import org
.eclipse
.jdt
.annotation
.NonNull
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.kernel
.core
.analysis
.vm
.trace
.VirtualMachineExperiment
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.experiment
.TmfExperiment
;
28 * List virtual machine experiments that can be used in unit tests
30 * @author Geneviève Bastien
32 public enum VmTestExperiment
{
35 * Virtual machine experiment: 1 guest, 1 host, using QEMU/KVM model
37 ONE_QEMUKVM(VmTraces
.HOST_ONE_QEMUKVM
, VmTraces
.GUEST_ONE_QEMUKVM
);
39 private Set
<VmTraces
> fTraces
= new HashSet
<>();
41 private VmTestExperiment(VmTraces
... traces
) {
42 for (VmTraces trace
: traces
) {
48 * Return a VirtualMachineExperiment object for this experiment with all its
49 * traces. It will be already initTrace()'ed.
51 * Make sure you call {@link #exists()} before calling this! This will make
52 * sure all traces in the experiment are available
54 * After being used by unit tests, the experiment must be properly disposed
55 * of by calling the {@link VirtualMachineExperiment#dispose()} method on
56 * the object returned by this method.
58 * @param deleteSuppFiles
59 * Indicate whether to make sure supplementary files are deleted
60 * @return A VirtualMachineExperiment object corresponding to this
63 public synchronized TmfExperiment
getExperiment(boolean deleteSuppFiles
) {
64 Set
<@NonNull ITmfTrace
> traces
= new HashSet
<>();
65 for (VmTraces trace
: fTraces
) {
66 ITmfTrace tmfTrace
= trace
.getTrace();
67 if (tmfTrace
!= null) {
71 String expName
= checkNotNull(this.name());
72 VirtualMachineExperiment experiment
= new VirtualMachineExperiment(expName
, traces
);
73 if (deleteSuppFiles
) {
75 * Delete the supplementary files, so that the next iteration
76 * rebuilds the state system.
78 File suppDir
= new File(TmfTraceManager
.getSupplementaryFileDir(experiment
));
79 for (File file
: suppDir
.listFiles()) {
87 * Check if all the traces actually exist on disk or not.
89 * @return If all traces for this experiment are present
91 public boolean exists() {
92 boolean exists
= true;
93 for (VmTraces trace
: fTraces
) {
94 exists
&= trace
.exists();