Commit | Line | Data |
---|---|---|
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 | ||
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 */ | |
6cd87900 AM |
34 | KERNEL_VM, |
35 | /** Trace synchronization: source trace */ | |
36 | SYNC_SRC, | |
37 | /** Trace synchronization: destination trace */ | |
a627ffb8 | 38 | SYNC_DEST, |
45f672d6 | 39 | /** UST trace with lots of lost events */ |
6e4358bd AM |
40 | HELLO_LOST, |
41 | /** UST trace with lttng-ust-cyg-profile events (aka -finstrument-functions) */ | |
42 | CYG_PROFILE, | |
43 | /** UST trace with lttng-ust-cyg-profile-fast events (no address in func_exit) */ | |
44 | CYG_PROFILE_FAST; | |
9ac63b5b AM |
45 | |
46 | ||
47 | private final String fPath; | |
48 | private CtfTmfTrace fTrace = null; | |
49 | ||
50 | private CtfTmfTestTrace() { | |
51 | /* This makes my head spin */ | |
52 | fPath = CtfTestTrace.valueOf(this.name()).getPath(); | |
53 | } | |
54 | ||
55 | /** | |
56 | * @return The path of this trace | |
57 | */ | |
58 | public String getPath() { | |
59 | return fPath; | |
60 | } | |
61 | ||
62 | /** | |
63 | * Return a CtfTmfTrace object of this test trace. It will be already | |
05383968 AM |
64 | * initTrace()'ed. You do not have to .dispose() the trace after use (the |
65 | * old one is disposed automatically when this method is called again). | |
9ac63b5b AM |
66 | * |
67 | * Make sure you call {@link #exists()} before calling this! | |
68 | * | |
69 | * @return A CtfTmfTrace reference to this trace | |
70 | */ | |
05383968 AM |
71 | public synchronized CtfTmfTrace getTrace() { |
72 | if (fTrace != null) { | |
73 | fTrace.dispose(); | |
74 | } | |
75 | fTrace = new CtfTmfTrace(); | |
76 | try { | |
77 | fTrace.initTrace(null, fPath, CtfTmfEvent.class); | |
78 | } catch (TmfTraceException e) { | |
79 | /* Should not happen if tracesExist() passed */ | |
80 | throw new RuntimeException(e); | |
9ac63b5b AM |
81 | } |
82 | return fTrace; | |
83 | } | |
84 | ||
85 | /** | |
86 | * Check if the trace actually exists on disk or not. | |
87 | * | |
88 | * @return If the trace is present | |
89 | */ | |
90 | public boolean exists() { | |
91 | return CtfTestTrace.valueOf(this.name()).exists(); | |
92 | } | |
93 | } |