Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 45609ecc84ed99964a86ef5907c35037eae70934 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package org.eclipse.linuxtools.ctf.core.tests;

import java.io.File;

import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;

/**
 * Here are the definitions common to all the CTF parser tests.
 * 
 * @author alexmont
 *
 */
public abstract class TestParams {
    
    /* Path to test traces */
    private static final String testTracePath1 = "Tests/traces/trace20m"; //$NON-NLS-1$
    private static CTFTrace testTrace1 = null;
    private static CTFTrace testTraceFromFile1 = null;
    
    private static final File emptyFile = new File(""); //$NON-NLS-1$
    private static CTFTrace emptyTrace = null;
    
    public static File getEmptyFile() {
        return emptyFile;
    }
    
    public static CTFTrace getEmptyTrace() {
        if (emptyTrace == null) {
            try {
                emptyTrace = new CTFTrace(""); //$NON-NLS-1$
            } catch (CTFReaderException e) {
                /* We know this trace should exist */
                throw new RuntimeException(e);
            } 
        }
        return emptyTrace;
    }
    
    public static CTFTrace createTrace() {
        if (testTrace1 == null) {
            try {
                testTrace1 = new CTFTrace(testTracePath1);
            } catch (CTFReaderException e) {
                /* We know this trace should exist */
                throw new RuntimeException(e);
            }
        }
        return testTrace1;
    }

    public static CTFTrace createTraceFromFile() {
        if (testTraceFromFile1 == null) {
            try {
                testTraceFromFile1 = new CTFTrace(new File(testTracePath1));
            } catch (CTFReaderException e) {
                /* We know this trace should exist */
                throw new RuntimeException(e);
            }
        }
        return testTraceFromFile1;
    }
}

Back to the top