Merge branch 'master' into lttng-luna
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / shared / org / eclipse / linuxtools / tmf / core / tests / shared / CtfTmfTestTrace.java
CommitLineData
9ac63b5b
AM
1/*******************************************************************************
2 * Copyright (c) 2013 Ericsson
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 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.core.tests.shared;
14
15import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
16import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
17import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
18import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
beefb2d4 19import org.eclipse.linuxtools.tmf.tests.stubs.ctf.CtfTmfTraceStub;
9ac63b5b
AM
20
21/**
22 * Available CTF TMF test traces. Kind-of-extends {@link CtfTestTrace}.
23 *
24 * To run tests using these, you first need to run the "get-traces.[xml|sh]"
25 * script located under lttng/org.eclipse.linuxtools.ctf.core.tests/traces/ .
26 *
27 * @author Alexandre Montplaisir
28 */
29public enum CtfTmfTestTrace {
30 /** Example kernel trace */
31 KERNEL,
32 /** Another kernel trace */
33 TRACE2,
34 /** Kernel trace with event contexts */
6cd87900
AM
35 KERNEL_VM,
36 /** Trace synchronization: source trace */
37 SYNC_SRC,
38 /** Trace synchronization: destination trace */
a627ffb8 39 SYNC_DEST,
45f672d6 40 /** UST trace with lots of lost events */
6e4358bd
AM
41 HELLO_LOST,
42 /** UST trace with lttng-ust-cyg-profile events (aka -finstrument-functions) */
43 CYG_PROFILE,
44 /** UST trace with lttng-ust-cyg-profile-fast events (no address in func_exit) */
45 CYG_PROFILE_FAST;
9ac63b5b
AM
46
47
48 private final String fPath;
beefb2d4 49 private CtfTmfTraceStub fTrace = null;
9ac63b5b
AM
50
51 private CtfTmfTestTrace() {
52 /* This makes my head spin */
53 fPath = CtfTestTrace.valueOf(this.name()).getPath();
54 }
55
56 /**
57 * @return The path of this trace
58 */
59 public String getPath() {
60 return fPath;
61 }
62
63 /**
beefb2d4 64 * Return a CtfTmfTraceStub object of this test trace. It will be already
05383968
AM
65 * initTrace()'ed. You do not have to .dispose() the trace after use (the
66 * old one is disposed automatically when this method is called again).
9ac63b5b
AM
67 *
68 * Make sure you call {@link #exists()} before calling this!
69 *
70 * @return A CtfTmfTrace reference to this trace
71 */
05383968
AM
72 public synchronized CtfTmfTrace getTrace() {
73 if (fTrace != null) {
74 fTrace.dispose();
75 }
beefb2d4 76 fTrace = new CtfTmfTraceStub();
05383968
AM
77 try {
78 fTrace.initTrace(null, fPath, CtfTmfEvent.class);
79 } catch (TmfTraceException e) {
80 /* Should not happen if tracesExist() passed */
81 throw new RuntimeException(e);
9ac63b5b
AM
82 }
83 return fTrace;
84 }
85
86 /**
87 * Check if the trace actually exists on disk or not.
88 *
89 * @return If the trace is present
90 */
91 public boolean exists() {
92 return CtfTestTrace.valueOf(this.name()).exists();
93 }
94}
This page took 0.030849 seconds and 5 git commands to generate.