1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
;
5 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
6 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
9 * Here are the definitions common to all the CTF parser tests.
13 @SuppressWarnings("nls")
14 public abstract class TestParams
{
17 * Path to test traces. Make sure you run the traces/get-traces.sh script
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");
25 private static final File emptyFile
= new File("");
26 private static CTFTrace emptyTrace
= null;
29 * Return an empty file (new File("");)
31 * @return An empty file
33 public static File
getEmptyFile() {
38 * Return a file in test trace #1 (channel0_0).
40 * Make sure {@link #tracesExist()} before calling this!
42 * @return A file in a test trace
44 public static File
getTraceFile(){
45 return testTraceFile1
;
49 * Return a trace out of an empty file (new CTFTrace("");)
51 * @return An empty trace
53 public static CTFTrace
getEmptyTrace() {
54 if (emptyTrace
== null) {
56 emptyTrace
= new CTFTrace("");
57 } catch (CTFReaderException e
) {
58 /* Should always work... */
59 throw new RuntimeException(e
);
66 * Get a CTFTrace reference to test trace #1.
68 * Make sure {@link #tracesExist()} before calling this!
70 * @return Reference to test trace #1
71 * @throws CTFReaderException
72 * If the trace cannot be found
74 public static CTFTrace
createTrace() throws CTFReaderException
{
75 if (testTrace1
== null) {
76 testTrace1
= new CTFTrace(testTracePath1
);
82 * Same as {@link #createTrace()}, except the CTFTrace is create from the
83 * File object and not the path.
85 * Make sure {@link #tracesExist()} before calling this!
87 * @return Reference to test trace #1
89 public static CTFTrace
createTraceFromFile() {
90 if (testTraceFromFile1
== null) {
92 testTraceFromFile1
= new CTFTrace(new File(testTracePath1
));
93 } catch (CTFReaderException e
) {
94 /* This trace should exist */
95 throw new RuntimeException(e
);
98 return testTraceFromFile1
;
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
105 * @return True if *all* the test files could be found, false otherwise.
107 public static boolean tracesExist() {
108 if (testTrace1
!= null) {
113 } catch (CTFReaderException e
) {