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
.io
.IOException
;
19 import org
.eclipse
.core
.runtime
.FileLocator
;
20 import org
.eclipse
.core
.runtime
.IPath
;
21 import org
.eclipse
.core
.runtime
.IStatus
;
22 import org
.eclipse
.core
.runtime
.Path
;
23 import org
.eclipse
.jdt
.annotation
.NonNull
;
24 import org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.tests
.Activator
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEvent
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfTraceException
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
28 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.xml
.TmfXmlTraceStub
;
31 * List the available virtual machine host and guest traces
33 * @author Geneviève Bastien
35 public enum VmTraces
{
37 /** Host from simple QEMU/KVM experiment */
38 HOST_ONE_QEMUKVM("vm/OneQemuKvm/host.xml"),
39 /** Guest from simple QEMU/KVM experiment */
40 GUEST_ONE_QEMUKVM("vm/OneQemuKvm/guest.xml");
42 private static final @NonNull String filePath
= "testfiles";
44 private final IPath fPath
;
46 VmTraces(String path
) {
47 IPath relativePath
= new Path(filePath
+ File
.separator
+ path
);
48 Activator plugin
= Activator
.getDefault();
51 * Shouldn't happen but at least throw something to get the test to
54 throw new IllegalStateException();
56 URL location
= FileLocator
.find(plugin
.getBundle(), relativePath
, null);
58 fPath
= new Path(FileLocator
.toFileURL(location
).getPath());
59 } catch (IOException e
) {
60 throw new IllegalStateException();
65 * Return a TmfXmlTraceStub object of this test trace. It will be already
68 * Make sure you call {@link #exists()} before calling this!
70 * @return A TmfXmlTraceStub reference to this trace
72 public ITmfTrace
getTrace() {
73 ITmfTrace trace
= new TmfXmlTraceStub();
74 IStatus status
= trace
.validate(null, fPath
.toOSString());
79 trace
.initTrace(null, fPath
.toOSString(), TmfEvent
.class);
80 } catch (TmfTraceException e
) {
87 * Check if the trace actually exists on disk or not.
89 * @return If the trace is present
91 public boolean exists() {
92 return fPath
.toFile().exists();
This page took 0.041982 seconds and 5 git commands to generate.