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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*******************************************************************************
* Copyright (c) 2009, 2010 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Francois Chouinard - Initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.lttng.tests.trace;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import junit.framework.TestCase;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.lttng.event.LttngEvent;
import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin;
import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
/**
* <b><u>TmfExperimentTest</u></b>
* <p>
* TODO: Implement me. Please.
*/
@SuppressWarnings("nls")
public class LTTngExperimentTest extends TestCase {
private static final String DIRECTORY = "traceset";
private static final String TEST_STREAM = "trace-15316events_nolost_newformat";
private static final String EXPERIMENT = "MyExperiment";
private static int NB_EVENTS = 15316;
// Note: Start/end times are for the LTTng *trace*, not the actual events
private static final TmfTimestamp fStartTime = new TmfTimestamp(13589759412128L, (byte) -9);
private static final TmfTimestamp fEndTime = new TmfTimestamp(13589907059242L, (byte) -9);
private static ITmfTrace<LttngEvent>[] fTraces;
private static TmfExperiment<LttngEvent> fExperiment;
// ------------------------------------------------------------------------
// Housekeeping
// ------------------------------------------------------------------------
@SuppressWarnings("unchecked")
private synchronized static ITmfTrace<LttngEvent>[] setupTrace(String path) {
if (fTraces == null) {
fTraces = new ITmfTrace[1];
try {
URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(path), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
LTTngTrace trace = new LTTngTrace(testfile.getPath(), false);
fTraces[0] = trace;
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
return fTraces;
}
private synchronized static void setupExperiment() {
if (fExperiment == null) {
fExperiment = new TmfExperiment<LttngEvent>(LttngEvent.class, EXPERIMENT, fTraces, TmfTimestamp.Zero, 1000, true);
}
}
public LTTngExperimentTest(String name) throws Exception {
super(name);
}
@Override
protected void setUp() throws Exception {
super.setUp();
setupTrace(DIRECTORY + File.separator + TEST_STREAM);
setupExperiment();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
public void testBasicTmfExperimentConstructor() {
assertEquals("GetId", EXPERIMENT, fExperiment.getName());
assertEquals("GetEpoch", TmfTimestamp.Zero, fExperiment.getEpoch());
assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
long nbTraceEvents = fExperiment.getTraces()[0].getNbEvents();
assertEquals("GetNbEvents", NB_EVENTS, nbTraceEvents);
TmfTimeRange timeRange = fExperiment.getTimeRange();
assertTrue("getStartTime", fStartTime.equals(timeRange.getStartTime()));
assertTrue("getEndTime", fEndTime.equals(timeRange.getEndTime()));
}
}
|