tmf: Add unit tests for lost events in CTF traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / shared / org / eclipse / linuxtools / tmf / core / tests / shared / CtfTmfTestTrace.java
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
13 package org.eclipse.linuxtools.tmf.core.tests.shared;
14
15 import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
16 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
17 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
18 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
19
20 /**
21 * Available CTF TMF test traces. Kind-of-extends {@link CtfTestTrace}.
22 *
23 * To run tests using these, you first need to run the "get-traces.[xml|sh]"
24 * script located under lttng/org.eclipse.linuxtools.ctf.core.tests/traces/ .
25 *
26 * @author Alexandre Montplaisir
27 */
28 public enum CtfTmfTestTrace {
29 /** Example kernel trace */
30 KERNEL,
31 /** Another kernel trace */
32 TRACE2,
33 /** Kernel trace with event contexts */
34 KERNEL_VM,
35 /** UST trace with lots of lost events */
36 HELLO_LOST;
37
38
39 private final String fPath;
40 private CtfTmfTrace fTrace = null;
41
42 private CtfTmfTestTrace() {
43 /* This makes my head spin */
44 fPath = CtfTestTrace.valueOf(this.name()).getPath();
45 }
46
47 /**
48 * @return The path of this trace
49 */
50 public String getPath() {
51 return fPath;
52 }
53
54 /**
55 * Return a CtfTmfTrace object of this test trace. It will be already
56 * initTrace()'ed.
57 *
58 * Make sure you call {@link #exists()} before calling this!
59 *
60 * @return A CtfTmfTrace reference to this trace
61 */
62 public CtfTmfTrace getTrace() {
63 if (fTrace == null) {
64 CtfTmfTrace trace = new CtfTmfTrace();
65 try {
66 trace.initTrace(null, fPath, CtfTmfEvent.class);
67 } catch (TmfTraceException e) {
68 /* Should not happen if tracesExist() passed */
69 throw new RuntimeException(e);
70 }
71 fTrace = trace;
72 }
73 return fTrace;
74 }
75
76 /**
77 * Check if the trace actually exists on disk or not.
78 *
79 * @return If the trace is present
80 */
81 public boolean exists() {
82 return CtfTestTrace.valueOf(this.name()).exists();
83 }
84 }
This page took 0.03539 seconds and 5 git commands to generate.