1
/*******************************************************************************
2
* Copyright (c) 2009, 2010 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
* Francois Chouinard - Initial API and implementation
11
*******************************************************************************/
13
package org.eclipse.linuxtools.lttng.core.tests.trace;
16
import java.io.IOException;
17
import java.net.URISyntaxException;
20
import junit.framework.TestCase;
22
import org.eclipse.core.runtime.FileLocator;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
25
import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
26
import org.eclipse.linuxtools.internal.lttng.core.trace.LTTngTrace;
27
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
28
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
29
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
30
import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
31
import org.osgi.framework.FrameworkUtil;
34
* <b><u>TmfExperimentTest</u></b>
36
* TODO: Implement me. Please.
38
@SuppressWarnings("nls")
39
public class LTTngExperimentTest extends TestCase {
41
private static final String DIRECTORY = "traceset";
42
private static final String TEST_STREAM = "trace-15316events_nolost_newformat";
43
private static final String EXPERIMENT = "MyExperiment";
44
private static int NB_EVENTS = 15316;
46
// Note: Start/end times are for the LTTng *trace*, not the actual events
47
private static final TmfTimestamp fStartTime = new LttngTimestamp(13589759412128L);
48
private static final TmfTimestamp fEndTime = new LttngTimestamp(13589906758692L);
50
private static ITmfTrace<LttngEvent>[] fTestTraces;
51
private static TestExperiment fExperiment;
53
// ------------------------------------------------------------------------
55
// ------------------------------------------------------------------------
57
private static class TestExperiment extends TmfExperiment<LttngEvent> {
58
public TestExperiment() {
59
super(LttngEvent.class, EXPERIMENT, fTestTraces, 1000);
60
getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, true);
64
// ------------------------------------------------------------------------
66
// ------------------------------------------------------------------------
68
@SuppressWarnings("unchecked")
69
private synchronized static ITmfTrace<LttngEvent>[] setupTrace(final String path) {
70
if (fTestTraces == null) {
71
fTestTraces = new ITmfTrace[1];
73
final URL location = FileLocator.find(FrameworkUtil.getBundle(LTTngExperimentTest.class), new Path(path), null);
74
final File testfile = new File(FileLocator.toFileURL(location).toURI());
75
final LTTngTrace trace = new LTTngTrace(null, testfile.getPath(), false);
76
fTestTraces[0] = trace;
77
} catch (final URISyntaxException e) {
79
} catch (final IOException e) {
81
} catch (final Exception e) {
88
private synchronized static void setupExperiment() {
89
if (fExperiment == null) {
90
fExperiment = new TestExperiment();
94
public LTTngExperimentTest(final String name) throws Exception {
99
protected void setUp() throws Exception {
101
setupTrace(DIRECTORY + File.separator + TEST_STREAM);
106
protected void tearDown() throws Exception {
110
// ------------------------------------------------------------------------
112
// ------------------------------------------------------------------------
114
public void testBasicTmfExperimentConstructor() {
116
assertEquals("GetId", EXPERIMENT, fExperiment.getName());
117
assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
119
final long nbTraceEvents = fExperiment.getTraces()[0].getNbEvents();
120
assertEquals("GetNbEvents", NB_EVENTS, nbTraceEvents);
122
final TmfTimeRange timeRange = fExperiment.getTimeRange();
123
assertEquals("getStartTime", fStartTime, timeRange.getStartTime());
124
assertEquals("getEndTime", fEndTime, timeRange.getEndTime());
b'\\ No newline at end of file'