Commit | Line | Data |
---|---|---|
866e5b51 FC |
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. | |
ce2388e0 | 10 | * |
866e5b51 FC |
11 | * @author alexmont |
12 | * | |
13 | */ | |
14 | public abstract class TestParams { | |
ce2388e0 | 15 | |
813ecc8e AM |
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"; //$NON-NLS-1$ | |
866e5b51 FC |
21 | private static CTFTrace testTrace1 = null; |
22 | private static CTFTrace testTraceFromFile1 = null; | |
bfe038ff | 23 | private static final File testTraceFile1 = new File(testTracePath1+"/channel0_0"); //$NON-NLS-1$ |
ce2388e0 | 24 | |
866e5b51 FC |
25 | private static final File emptyFile = new File(""); //$NON-NLS-1$ |
26 | private static CTFTrace emptyTrace = null; | |
ce2388e0 | 27 | |
866e5b51 FC |
28 | public static File getEmptyFile() { |
29 | return emptyFile; | |
30 | } | |
ce2388e0 | 31 | |
024373d7 MK |
32 | public static File getTraceFile(){ |
33 | return testTraceFile1; | |
34 | } | |
866e5b51 FC |
35 | public static CTFTrace getEmptyTrace() { |
36 | if (emptyTrace == null) { | |
37 | try { | |
38 | emptyTrace = new CTFTrace(""); //$NON-NLS-1$ | |
39 | } catch (CTFReaderException e) { | |
40 | /* We know this trace should exist */ | |
41 | throw new RuntimeException(e); | |
ce2388e0 | 42 | } |
866e5b51 FC |
43 | } |
44 | return emptyTrace; | |
45 | } | |
ce2388e0 | 46 | |
13be1a8f | 47 | public static CTFTrace createTrace() throws CTFReaderException { |
866e5b51 | 48 | if (testTrace1 == null) { |
13be1a8f | 49 | testTrace1 = new CTFTrace(testTracePath1); |
866e5b51 FC |
50 | } |
51 | return testTrace1; | |
52 | } | |
53 | ||
54 | public static CTFTrace createTraceFromFile() { | |
55 | if (testTraceFromFile1 == null) { | |
56 | try { | |
57 | testTraceFromFile1 = new CTFTrace(new File(testTracePath1)); | |
58 | } catch (CTFReaderException e) { | |
59 | /* We know this trace should exist */ | |
60 | throw new RuntimeException(e); | |
61 | } | |
62 | } | |
63 | return testTraceFromFile1; | |
64 | } | |
65 | } |