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
.jdt
.annotation
.Nullable
;
25 import org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.tests
.Activator
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEvent
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfTraceException
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
29 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.xml
.TmfXmlTraceStub
;
32 * List the available virtual machine host and guest traces
34 * @author Geneviève Bastien
36 public enum VmTraces
{
38 /** Host from simple QEMU/KVM experiment */
39 HOST_ONE_QEMUKVM("vm/OneQemuKvm/host.xml"),
40 /** Guest from simple QEMU/KVM experiment */
41 GUEST_ONE_QEMUKVM("vm/OneQemuKvm/guest.xml");
43 private static final @NonNull String filePath
= "testfiles";
45 private final IPath fPath
;
47 VmTraces(String path
) {
48 IPath relativePath
= new Path(filePath
+ File
.separator
+ path
);
49 Activator plugin
= Activator
.getDefault();
52 * Shouldn't happen but at least throw something to get the test to
55 throw new IllegalStateException();
57 URL location
= FileLocator
.find(plugin
.getBundle(), relativePath
, null);
59 fPath
= new Path(FileLocator
.toFileURL(location
).getPath());
60 } catch (IOException e
) {
61 throw new IllegalStateException();
66 * Return a TmfXmlTraceStub object of this test trace. It will be already
69 * Make sure you call {@link #exists()} before calling this!
71 * @return A TmfXmlTraceStub reference to this trace
73 public @Nullable ITmfTrace
getTrace() {
74 ITmfTrace trace
= new TmfXmlTraceStub();
75 IStatus status
= trace
.validate(null, fPath
.toOSString());
80 trace
.initTrace(null, fPath
.toOSString(), TmfEvent
.class);
81 } catch (TmfTraceException e
) {
88 * Check if the trace actually exists on disk or not.
90 * @return If the trace is present
92 public boolean exists() {
93 return fPath
.toFile().exists();
This page took 0.035519 seconds and 5 git commands to generate.