ctf: add synthetic LTTng kernel trace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / shared / org / eclipse / linuxtools / ctf / core / tests / shared / CtfTestTrace.java
CommitLineData
9ac63b5b
AM
1/*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Alexandre Montplaisir - Initial API and implementation
10 *******************************************************************************/
11
12package org.eclipse.linuxtools.ctf.core.tests.shared;
13
14import java.io.File;
15
c2fa72bc 16import org.eclipse.linuxtools.ctf.core.tests.synthetictraces.LttngKernelTraceGenerator;
9ac63b5b
AM
17import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
18import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
19
20/**
21 * Here is the list of the available test traces for the CTF parser.
22 *
a74472c3
AM
23 * Make sure you run the traces/get-traces.xml Ant script to download them
24 * first!
9ac63b5b
AM
25 *
26 * @author Alexandre Montplaisir
27 */
28public enum CtfTestTrace {
29 /** Example kernel trace */
30 KERNEL("../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"),
31 /** Another kernel trace */
32 TRACE2("../org.eclipse.linuxtools.ctf.core.tests/traces/trace2"),
33 /** Kernel trace with event contexts */
45f672d6
AM
34 KERNEL_VM("../org.eclipse.linuxtools.ctf.core.tests/traces/kernel_vm"),
35 /** UST trace with lots of lost events */
c2fa72bc
MK
36 HELLO_LOST("../org.eclipse.linuxtools.ctf.core.tests/traces/hello-lost"),
37 /** Autogenerated Syntetic trace */
38 SYNTHETIC_TRACE(LttngKernelTraceGenerator.getPath());
9ac63b5b
AM
39
40
41 private final String fPath;
42 private CTFTrace fTrace = null;
43 private CTFTrace fTraceFromFile = null;
44
45 private CtfTestTrace(String path) {
46 fPath = path;
47 }
48
49 /** @return The path to the test trace */
50 public String getPath() {
51 return fPath;
52 }
53
54 /**
55 * Get a CTFTrace instance of a test trace. Make sure
56 * {@link #exists()} before calling this!
57 *
58 * @return The CTFTrace object
59 * @throws CTFReaderException
60 * If the trace cannot be found.
61 */
62 public CTFTrace getTrace() throws CTFReaderException {
63 if (fTrace == null) {
64 fTrace = new CTFTrace(fPath);
65 }
66 return fTrace;
67 }
68
69 /**
70 * Get a CTFTrace instance created from a File. Make sure
71 * {@link #exists()} before calling this!
72 *
73 * @return The CTFTrace object
74 * @throws CTFReaderException
75 * If the trace cannot be found.
76 */
77 public CTFTrace getTraceFromFile() throws CTFReaderException {
78 if (fTraceFromFile == null) {
79 fTraceFromFile = new CTFTrace(new File(fPath));
80 }
81 return fTraceFromFile;
82 }
83
84 /**
85 * Check if this test trace actually exists on disk.
86 *
87 * @return If the trace exists
88 */
89 public boolean exists() {
90 try {
91 getTrace();
92 } catch (CTFReaderException e) {
93 return false;
94 }
95 return true;
96 }
97}
This page took 0.028901 seconds and 5 git commands to generate.