[CTF] Events wrongly parsed as Lost Events
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.tmf.ctf.core.tests / shared / org / eclipse / tracecompass / tmf / ctf / core / tests / shared / CtfTmfTestTrace.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 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
13 package org.eclipse.tracecompass.tmf.ctf.core.tests.shared;
14
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
19 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
20 import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
21 import org.eclipse.tracecompass.tmf.ctf.core.tests.stubs.CtfTmfTraceStub;
22 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
23
24 /**
25 * Available CTF TMF test traces. Kind-of-extends {@link CtfTestTrace}.
26 *
27 * To run tests using these, you first need to run the "get-traces.[xml|sh]"
28 * script located under lttng/org.eclipse.tracecompass.ctf.core.tests/traces/ .
29 *
30 * @author Alexandre Montplaisir
31 */
32 @NonNullByDefault
33 public enum CtfTmfTestTrace {
34 /** Example kernel trace */
35 KERNEL,
36 /** Another kernel trace */
37 TRACE2,
38 /** Kernel trace with event contexts */
39 KERNEL_VM,
40 /** Trace synchronization: source trace */
41 SYNC_SRC,
42 /** Trace synchronization: destination trace */
43 SYNC_DEST,
44 /** Trace synchronization (case 2): django client trace */
45 DJANGO_CLIENT,
46 /** Trace synchronization (case 2): django db trace */
47 DJANGO_DB,
48 /** Trace synchronization (case 2): django web server trace */
49 DJANGO_HTTPD,
50 /** UST trace with lots of lost events */
51 HELLO_LOST,
52 /** UST trace with lttng-ust-cyg-profile events (aka -finstrument-functions) */
53 CYG_PROFILE,
54 /** UST trace with lttng-ust-cyg-profile-fast events (no address in func_exit) */
55 CYG_PROFILE_FAST,
56 /** Autogenerated Syntetic trace */
57 SYNTHETIC_TRACE,
58 /** Trace with non-standard field sizes */
59 FUNKY_TRACE,
60 /** Example dynamic scope, timestamp in field, empty stream trace */
61 DYNSCOPE;
62
63
64 private final String fPath;
65 private @Nullable CtfTmfTraceStub fTrace = null;
66
67 private CtfTmfTestTrace() {
68 @SuppressWarnings("null")
69 @NonNull String path = CtfTestTrace.valueOf(this.name()).getPath();
70 fPath = path;
71 }
72
73 /**
74 * @return The path of this trace
75 */
76 public String getPath() {
77 return fPath;
78 }
79
80 /**
81 * Return a CtfTmfTraceStub object of this test trace. It will be already
82 * initTrace()'ed.
83 *
84 * Make sure you call {@link #exists()} before calling this!
85 *
86 * After being used by unit tests, traces must be properly disposed of by
87 * calling the {@link CtfTmfTestTrace#dispose()} method.
88 *
89 * @return A CtfTmfTrace reference to this trace
90 */
91 public synchronized CtfTmfTrace getTrace() {
92 CtfTmfTraceStub trace = fTrace;
93 if (trace != null) {
94 trace.close();
95 }
96 trace = new CtfTmfTraceStub();
97 try {
98 trace.initTrace(null, fPath, CtfTmfEvent.class);
99 } catch (TmfTraceException e) {
100 /* Should not happen if tracesExist() passed */
101 throw new RuntimeException(e);
102 }
103 fTrace = trace;
104 return trace;
105 }
106
107 /**
108 * Check if the trace actually exists on disk or not.
109 *
110 * @return If the trace is present
111 */
112 public boolean exists() {
113 return CtfTestTrace.valueOf(this.name()).exists();
114 }
115
116 /**
117 * Dispose of the trace
118 */
119 public void dispose() {
120 if (fTrace != null) {
121 fTrace.dispose();
122 fTrace = null;
123 }
124 }
125 }
This page took 0.046213 seconds and 5 git commands to generate.