tmf: Fix set focus on SWT Chart viewers
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.core.tests / shared / org / eclipse / tracecompass / lttng2 / lttng / kernel / core / tests / shared / vm / VmTestExperiment.java
CommitLineData
03722d5b
GB
1/*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
3 *
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
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm;
14
15import java.io.File;
16import java.util.HashSet;
17import java.util.Set;
18
19import org.eclipse.jdt.annotation.NonNull;
20import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.vm.trace.VirtualMachineExperiment;
21import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
22import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
23
24/**
25 * List virtual machine experiments that can be used in unit tests
26 *
27 * @author Geneviève Bastien
28 */
29public enum VmTestExperiment {
30
31 /**
32 * Virtual machine experiment: 1 guest, 1 host, using QEMU/KVM model
33 */
34 ONE_QEMUKVM(VmTraces.HOST_ONE_QEMUKVM, VmTraces.GUEST_ONE_QEMUKVM);
35
36 private Set<VmTraces> fTraces = new HashSet<>();
37
38 private VmTestExperiment(VmTraces... traces) {
39 for (VmTraces trace : traces) {
40 fTraces.add(trace);
41 }
42 }
43
44 /**
45 * Return a VirtualMachineExperiment object for this experiment with all its
46 * traces. It will be already initTrace()'ed.
47 *
48 * Make sure you call {@link #exists()} before calling this! This will make
49 * sure all traces in the experiment are available
50 *
51 * After being used by unit tests, the experiment must be properly disposed
52 * of by calling the {@link VirtualMachineExperiment#dispose()} method on
53 * the object returned by this method.
54 *
55 * @param deleteSuppFiles
56 * Indicate whether to make sure supplementary files are deleted
57 * @return A VirtualMachineExperiment object corresponding to this
58 * experiment
59 */
60 public synchronized VirtualMachineExperiment getExperiment(boolean deleteSuppFiles) {
61 Set<ITmfTrace> traces = new HashSet<>();
62 for (VmTraces trace : fTraces) {
63 traces.add(trace.getTrace());
64 }
65 @SuppressWarnings("null")
66 @NonNull String expName = this.name();
67 VirtualMachineExperiment experiment = new VirtualMachineExperiment(expName, traces);
68 if (deleteSuppFiles) {
69 /*
70 * Delete the supplementary files, so that the next iteration
71 * rebuilds the state system.
72 */
73 File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(experiment));
74 for (File file : suppDir.listFiles()) {
75 file.delete();
76 }
77 }
78 return experiment;
79 }
80
81 /**
82 * Check if all the traces actually exist on disk or not.
83 *
84 * @return If all traces for this experiment are present
85 */
86 public boolean exists() {
87 boolean exists = true;
88 for (VmTraces trace : fTraces) {
89 exists &= trace.exists();
90 }
91 return exists;
92 }
93
94}
This page took 0.034499 seconds and 5 git commands to generate.