[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
CommitLineData
9ac63b5b 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2013, 2014 Ericsson
9ac63b5b
AM
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
2bdf0193 13package org.eclipse.tracecompass.tmf.ctf.core.tests.shared;
9ac63b5b 14
a63890ce
AM
15import org.eclipse.jdt.annotation.NonNull;
16import org.eclipse.jdt.annotation.NonNullByDefault;
17import org.eclipse.jdt.annotation.Nullable;
f357bcd4 18import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
2bdf0193 19import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
9722e5d7 20import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
2bdf0193 21import org.eclipse.tracecompass.tmf.ctf.core.tests.stubs.CtfTmfTraceStub;
9722e5d7 22import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
9ac63b5b
AM
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]"
c77a695a 28 * script located under lttng/org.eclipse.tracecompass.ctf.core.tests/traces/ .
9ac63b5b
AM
29 *
30 * @author Alexandre Montplaisir
31 */
a63890ce 32@NonNullByDefault
9ac63b5b
AM
33public enum CtfTmfTestTrace {
34 /** Example kernel trace */
35 KERNEL,
36 /** Another kernel trace */
37 TRACE2,
38 /** Kernel trace with event contexts */
6cd87900
AM
39 KERNEL_VM,
40 /** Trace synchronization: source trace */
41 SYNC_SRC,
42 /** Trace synchronization: destination trace */
a627ffb8 43 SYNC_DEST,
ef3a9bfd
GB
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,
45f672d6 50 /** UST trace with lots of lost events */
6e4358bd
AM
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) */
d957af45 55 CYG_PROFILE_FAST,
c2fa72bc 56 /** Autogenerated Syntetic trace */
9ab4ca26
AM
57 SYNTHETIC_TRACE,
58 /** Trace with non-standard field sizes */
dd7f1879
MAL
59 FUNKY_TRACE,
60 /** Example dynamic scope, timestamp in field, empty stream trace */
61 DYNSCOPE;
9ac63b5b
AM
62
63
64 private final String fPath;
a63890ce 65 private @Nullable CtfTmfTraceStub fTrace = null;
9ac63b5b
AM
66
67 private CtfTmfTestTrace() {
a63890ce
AM
68 @SuppressWarnings("null")
69 @NonNull String path = CtfTestTrace.valueOf(this.name()).getPath();
70 fPath = path;
9ac63b5b
AM
71 }
72
73 /**
74 * @return The path of this trace
75 */
76 public String getPath() {
77 return fPath;
78 }
79
80 /**
beefb2d4 81 * Return a CtfTmfTraceStub object of this test trace. It will be already
b5ddd705 82 * initTrace()'ed.
9ac63b5b
AM
83 *
84 * Make sure you call {@link #exists()} before calling this!
85 *
b5ddd705
GB
86 * After being used by unit tests, traces must be properly disposed of by
87 * calling the {@link CtfTmfTestTrace#dispose()} method.
88 *
9ac63b5b
AM
89 * @return A CtfTmfTrace reference to this trace
90 */
05383968 91 public synchronized CtfTmfTrace getTrace() {
a63890ce
AM
92 CtfTmfTraceStub trace = fTrace;
93 if (trace != null) {
94 trace.close();
05383968 95 }
a63890ce 96 trace = new CtfTmfTraceStub();
05383968 97 try {
a63890ce 98 trace.initTrace(null, fPath, CtfTmfEvent.class);
05383968
AM
99 } catch (TmfTraceException e) {
100 /* Should not happen if tracesExist() passed */
101 throw new RuntimeException(e);
9ac63b5b 102 }
a63890ce
AM
103 fTrace = trace;
104 return trace;
9ac63b5b
AM
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 }
b5ddd705
GB
115
116 /**
117 * Dispose of the trace
118 */
119 public void dispose() {
120 if (fTrace != null) {
121 fTrace.dispose();
122 fTrace = null;
123 }
124 }
9ac63b5b 125}
This page took 0.06843 seconds and 5 git commands to generate.