Add support for streaming feature of LTTng Tools 2.1 (part 1)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / TestParams.java
1 package org.eclipse.linuxtools.ctf.core.tests;
2
3 import java.io.File;
4
5 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
6 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
7
8 /**
9 * Here are the definitions common to all the CTF parser tests.
10 *
11 * @author alexmont
12 */
13 @SuppressWarnings("nls")
14 public abstract class TestParams {
15
16 /*
17 * Path to test traces. Make sure you run the traces/get-traces.sh script
18 * first!
19 */
20 private static final String testTracePath1 = "traces/kernel";
21 private static CTFTrace testTrace1 = null;
22 private static CTFTrace testTraceFromFile1 = null;
23 private static final File testTraceFile1 = new File(testTracePath1 + "/channel0_0");
24
25 private static final File emptyFile = new File("");
26 private static CTFTrace emptyTrace = null;
27
28 /**
29 * Return an empty file (new File("");)
30 *
31 * @return An empty file
32 */
33 public static File getEmptyFile() {
34 return emptyFile;
35 }
36
37 /**
38 * Return a file in test trace #1 (channel0_0).
39 *
40 * Make sure {@link #tracesExist()} before calling this!
41 *
42 * @return A file in a test trace
43 */
44 public static File getTraceFile(){
45 return testTraceFile1;
46 }
47
48 /**
49 * Return a trace out of an empty file (new CTFTrace("");)
50 *
51 * @return An empty trace
52 */
53 public static CTFTrace getEmptyTrace() {
54 if (emptyTrace == null) {
55 try {
56 emptyTrace = new CTFTrace("");
57 } catch (CTFReaderException e) {
58 /* Should always work... */
59 throw new RuntimeException(e);
60 }
61 }
62 return emptyTrace;
63 }
64
65 /**
66 * Get a CTFTrace reference to test trace #1.
67 *
68 * Make sure {@link #tracesExist()} before calling this!
69 *
70 * @return Reference to test trace #1
71 * @throws CTFReaderException
72 * If the trace cannot be found
73 */
74 public static CTFTrace createTrace() throws CTFReaderException {
75 if (testTrace1 == null) {
76 testTrace1 = new CTFTrace(testTracePath1);
77 }
78 return testTrace1;
79 }
80
81 /**
82 * Same as {@link #createTrace()}, except the CTFTrace is create from the
83 * File object and not the path.
84 *
85 * Make sure {@link #tracesExist()} before calling this!
86 *
87 * @return Reference to test trace #1
88 */
89 public static CTFTrace createTraceFromFile() {
90 if (testTraceFromFile1 == null) {
91 try {
92 testTraceFromFile1 = new CTFTrace(new File(testTracePath1));
93 } catch (CTFReaderException e) {
94 /* This trace should exist */
95 throw new RuntimeException(e);
96 }
97 }
98 return testTraceFromFile1;
99 }
100
101 /**
102 * Check if the test traces are present in the tree. If not, you can get
103 * them by running traces/get-traces.sh or traces/get-traces.xml
104 *
105 * @return True if *all* the test files could be found, false otherwise.
106 */
107 public static boolean tracesExist() {
108 if (testTrace1 != null) {
109 return true;
110 }
111 try {
112 createTrace();
113 } catch (CTFReaderException e) {
114 return false;
115 }
116 return true;
117 }
118 }
This page took 0.034987 seconds and 5 git commands to generate.