1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
;
17 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.shared
.CtfTestTraces
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEvent
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfTrace
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
23 * Definitions used by all tests using CTF-TMF trace files.
25 * To run these tests, you will first need to run the "get-traces.sh" script
26 * located under lttng/org.eclipse.linuxtools.ctf.core.tests/traces/ .
28 * @author Alexandre Montplaisir
30 public final class CtfTmfTestTraces
{
32 private CtfTmfTestTraces() {}
34 private static final File emptyFile
= new File("");
35 private static CtfTmfTrace emptyTrace
= new CtfTmfTrace();
37 private static CtfTmfTrace
[] testTraces
= new CtfTmfTrace
[3];
40 * Get an empty File (new File("");)
42 * @return An empty file
44 public static File
getEmptyFile() {
49 * Get an empty CtfTmfTrace (new CtfTmfTrace();)
51 * @return An empty trace
53 public static CtfTmfTrace
getEmptyTrace() {
58 * Get a reference to the test trace used for the kernel event handler unit
61 * Make sure you call {@link #tracesExist()} before calling this!
64 * The index of the test trace you want
65 * @return A CtfTmfTrace reference to the test trace
67 public synchronized static CtfTmfTrace
getTestTrace(int idx
) {
68 if (testTraces
[idx
] == null) {
69 String tracePath
= CtfTestTraces
.getTestTracePath(idx
);
70 testTraces
[idx
] = new CtfTmfTrace();
72 testTraces
[idx
].initTrace(null, tracePath
, CtfTmfEvent
.class);
73 } catch (TmfTraceException e
) {
74 /* Should not happen if tracesExist() passed */
75 testTraces
[idx
] = null;
76 throw new RuntimeException(e
);
79 return testTraces
[idx
];
82 // ------------------------------------------------------------------------
83 // Wrappers around direct CtfTestTraces methods
84 // ------------------------------------------------------------------------
87 * Get the (string) path to a given test trace.
89 * You should call {@link #tracesExist()} before calling this if you are
90 * going to use this trace for real.
93 * The index of the trace among all the available ones
94 * @return The path to the test trace
96 public static String
getTestTracePath(int idx
) {
97 return CtfTestTraces
.getTestTracePath(idx
);
101 * Check if the test traces are present before trying to open them.
103 * This should be called in unit tests within a asssumeTrue() call, to skip
104 * the test/test-class if the traces are not available.
106 * @return True if the trace is available, false if not
108 public static boolean tracesExist() {
109 return CtfTestTraces
.tracesExist();
This page took 0.03717 seconds and 5 git commands to generate.