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 | |
866e5b51 | 16 | /* Path to test traces */ |
ce2388e0 | 17 | private static final String testTracePath1 = "Tests/traces/trace20m1"; //$NON-NLS-1$ |
866e5b51 FC |
18 | private static CTFTrace testTrace1 = null; |
19 | private static CTFTrace testTraceFromFile1 = null; | |
ce2388e0 | 20 | |
866e5b51 FC |
21 | private static final File emptyFile = new File(""); //$NON-NLS-1$ |
22 | private static CTFTrace emptyTrace = null; | |
ce2388e0 | 23 | |
866e5b51 FC |
24 | public static File getEmptyFile() { |
25 | return emptyFile; | |
26 | } | |
ce2388e0 | 27 | |
866e5b51 FC |
28 | public static CTFTrace getEmptyTrace() { |
29 | if (emptyTrace == null) { | |
30 | try { | |
31 | emptyTrace = new CTFTrace(""); //$NON-NLS-1$ | |
32 | } catch (CTFReaderException e) { | |
33 | /* We know this trace should exist */ | |
34 | throw new RuntimeException(e); | |
ce2388e0 | 35 | } |
866e5b51 FC |
36 | } |
37 | return emptyTrace; | |
38 | } | |
ce2388e0 | 39 | |
13be1a8f | 40 | public static CTFTrace createTrace() throws CTFReaderException { |
866e5b51 | 41 | if (testTrace1 == null) { |
13be1a8f | 42 | testTrace1 = new CTFTrace(testTracePath1); |
866e5b51 FC |
43 | } |
44 | return testTrace1; | |
45 | } | |
46 | ||
47 | public static CTFTrace createTraceFromFile() { | |
48 | if (testTraceFromFile1 == null) { | |
49 | try { | |
50 | testTraceFromFile1 = new CTFTrace(new File(testTracePath1)); | |
51 | } catch (CTFReaderException e) { | |
52 | /* We know this trace should exist */ | |
53 | throw new RuntimeException(e); | |
54 | } | |
55 | } | |
56 | return testTraceFromFile1; | |
57 | } | |
58 | } |