1 package org
.eclipse
.linuxtools
.lttng
.core
.tests
.trace
;
6 import junit
.framework
.TestCase
;
8 import org
.eclipse
.core
.runtime
.FileLocator
;
9 import org
.eclipse
.core
.runtime
.Path
;
10 import org
.eclipse
.linuxtools
.internal
.lttng
.core
.event
.LttngLocation
;
11 import org
.eclipse
.linuxtools
.internal
.lttng
.core
.trace
.LTTngTrace
;
12 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEvent
;
13 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
14 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfContext
;
16 import org
.osgi
.framework
.FrameworkUtil
;
19 Functions tested here :
20 public LTTngTrace(String path) throws Exception
21 public LTTngTrace(String path, boolean skipIndexing) throws Exception
23 public TmfTraceContext seekLocation(Object location) {
24 public TmfTraceContext seekEvent(TmfTimestamp timestamp) {
25 public TmfTraceContext seekEvent(long position) {
27 public TmfEvent getNextEvent(TmfTraceContext context) {
28 public Object getCurrentLocation() {
30 public LttngEvent parseEvent(TmfTraceContext context) {
32 public int getCpuNumber() {
35 @SuppressWarnings("nls")
36 public class LTTngTraceTest
extends TestCase
{
38 private final static String tracepath1
="traceset/trace-15316events_nolost_newformat";
39 private final static String wrongTracePath
="/somewhere/that/does/not/exist";
41 private final static int traceCpuNumber
=1;
43 private final static boolean skipIndexing
=true;
45 private final static long firstEventTimestamp
= 13589759412128L;
46 private final static long secondEventTimestamp
= 13589759419903L;
47 private final static Long locationAfterFirstEvent
= 13589759412128L;
49 private final static String tracename
= "traceset/trace-15316events_nolost_newformat";
51 private final static long indexToSeekFirst
= 0;
52 private final static Long locationToSeekFirst
= 13589759412128L;
53 private final static long contextValueAfterFirstEvent
= 13589759412128L;
54 private final static String firstEventReference
= tracename
+ "/metadata_0";
57 private final static long timestampToSeekTest1
= 13589826657302L;
58 private final static Long indexToSeekTest1
= 7497L;
59 private final static long locationToSeekTest1
= 13589826657302L;
60 private final static long contextValueAfterSeekTest1
= 13589826657302L;
61 private final static String seek1EventReference
= tracename
+ "/vm_state_0";
62 private final static long seekTimestamp
= 13589826657302L;
63 private final static long nextEventTimestamp
= 13589826659739L;
64 private final static long nextnextEventTimestamp
= 13589826662017L;
66 private final static long timestampToSeekLast
= 13589906758692L;
67 private final static Long indexToSeekLast
= 15315L;
68 private final static long locationToSeekLast
= 13589906758692L;
69 private final static long contextValueAfterSeekLast
= 13589906758692L;
70 private final static String seekLastEventReference
= tracename
+ "/kernel_0";
72 private static LTTngTrace testStream
= null;
73 private LTTngTrace
prepareStreamToTest() {
74 if (testStream
== null)
76 final URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(tracepath1
), null);
77 final File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
78 final LTTngTrace tmpStream
= new LTTngTrace(null, testfile
.getPath(), false);
79 testStream
= tmpStream
;
81 catch (final Exception e
) {
82 System
.out
.println("ERROR : Could not open " + tracepath1
);
86 testStream
.seekEvent(0L);
92 public void testTraceConstructors() {
93 // Default constructor
94 // Test constructor with argument on a wrong tracepath, skipping indexing
96 new LTTngTrace(null, wrongTracePath
, skipIndexing
);
97 fail("Construction with wrong tracepath should fail!");
99 catch( final Exception e
) {
102 // Test constructor with argument on a correct tracepath, skipping indexing
104 final URL location
= FileLocator
.find(FrameworkUtil
.getBundle(this.getClass()), new Path(tracepath1
), null);
105 final File testfile
= new File(FileLocator
.toFileURL(location
).toURI());
106 new LTTngTrace(null, testfile
.getPath(), skipIndexing
);
108 catch( final Exception e
) {
109 fail("Construction with correct tracepath failed!");
111 // System.out.println("Test completed");
114 public void testGetNextEvent() {
115 TmfEvent tmpEvent
= null;
116 final LTTngTrace testStream1
= prepareStreamToTest();
118 final TmfContext tmpContext
= new TmfContext(null, 0);
119 // We should be at the beginning of the trace, so we will just read the first event now
120 tmpEvent
= testStream1
.getNext(tmpContext
);
121 assertNotSame("tmpEvent is null after first getNextEvent()",null,tmpEvent
);
122 assertEquals("tmpEvent has wrong timestamp after first getNextEvent()",firstEventTimestamp
,tmpEvent
.getTimestamp().getValue() );
124 // Read the next event as well
125 tmpEvent
= testStream1
.getNext( tmpContext
);
126 assertNotSame("tmpEvent is null after second getNextEvent()",null,tmpEvent
);
127 assertEquals("tmpEvent has wrong timestamp after second getNextEvent()",secondEventTimestamp
,tmpEvent
.getTimestamp().getValue() );
130 public void testParseEvent() {
131 TmfEvent tmpEvent
= null;
132 final LTTngTrace testStream1
= prepareStreamToTest();
134 final TmfContext tmpContext
= new TmfContext(null, 0);
135 // We should be at the beginning of the trace, so we will just parse the first event now
136 tmpEvent
= testStream1
.parseEvent(tmpContext
);
137 assertNotSame("tmpEvent is null after first parseEvent()",null,tmpEvent
);
138 assertEquals("tmpEvent has wrong timestamp after first parseEvent()",firstEventTimestamp
,tmpEvent
.getTimestamp().getValue() );
140 // Use parseEvent again. Should be the same event
141 tmpEvent
= testStream1
.parseEvent(tmpContext
);
142 assertNotSame("tmpEvent is null after first parseEvent()",null,tmpEvent
);
143 assertEquals("tmpEvent has wrong timestamp after first parseEvent()",firstEventTimestamp
,tmpEvent
.getTimestamp().getValue() );
146 public void testSeekEventTimestamp() {
147 TmfEvent tmpEvent
= null;
148 ITmfContext tmpContext
= new TmfContext(null, 0);
149 final LTTngTrace testStream1
= prepareStreamToTest();
151 // We should be at the beginning of the trace, we will seek at a certain timestamp
152 tmpContext
= testStream1
.seekEvent(new TmfTimestamp(timestampToSeekTest1
, (byte) -9, 0));
153 tmpEvent
= testStream1
.getNext(tmpContext
);
154 assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext
);
155 assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
156 assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent
);
157 assertTrue("tmpEvent has wrong reference after first seekEvent()", seek1EventReference
.contains(tmpEvent
.getReference()));
159 // Seek to the last timestamp
160 tmpContext
= testStream1
.seekEvent(new TmfTimestamp(timestampToSeekLast
, (byte) -9, 0));
161 tmpEvent
= testStream1
.getNext(tmpContext
);
162 assertNotSame("tmpContext is null after seekEvent() to last",null,tmpContext
);
163 assertEquals("tmpContext has wrong timestamp after seekEvent() to last",contextValueAfterSeekLast
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
164 assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent
);
165 assertTrue("tmpEvent has wrong reference after seekEvent() to last", seekLastEventReference
.contains(tmpEvent
.getReference()));
167 // Seek to the first timestamp (startTime)
168 tmpContext
= testStream1
.seekEvent(new TmfTimestamp(firstEventTimestamp
, (byte) -9, 0));
169 tmpEvent
= testStream1
.getNext(tmpContext
);
170 assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent
);
171 assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference
.contains(tmpEvent
.getReference()));
172 assertNotSame("tmpContext is null after seekEvent() to first",null,tmpContext
);
173 assertEquals("tmpContext has wrong timestamp after seekEvent() to first",contextValueAfterFirstEvent
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
176 public void testSeekEventIndex() {
177 TmfEvent tmpEvent
= null;
178 ITmfContext tmpContext
= new TmfContext(null, 0);
179 final LTTngTrace testStream1
= prepareStreamToTest();
181 // We should be at the beginning of the trace, we will seek at a certain timestamp
182 tmpContext
= testStream1
.seekEvent(indexToSeekTest1
);
183 tmpEvent
= testStream1
.getNext(tmpContext
);
184 assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext
);
185 assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekTest1
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
186 assertNotSame("tmpEvent is null after first seekEvent()",null,tmpEvent
);
187 assertTrue("tmpEvent has wrong reference after first seekEvent()", seek1EventReference
.contains(tmpEvent
.getReference()));
189 // Seek to the last timestamp
190 tmpContext
= testStream1
.seekEvent(indexToSeekLast
);
191 tmpEvent
= testStream1
.getNext(tmpContext
);
192 assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext
);
193 assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterSeekLast
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
194 assertNotSame("tmpEvent is null after seekEvent() to last ",null,tmpEvent
);
195 assertTrue("tmpEvent has wrong reference after seekEvent() to last", seekLastEventReference
.contains(tmpEvent
.getReference()));
197 // Seek to the first timestamp (startTime)
198 tmpContext
= testStream1
.seekEvent(indexToSeekFirst
);
199 tmpEvent
= testStream1
.getNext(tmpContext
);
200 assertNotSame("tmpContext is null after first seekEvent()",null,tmpContext
);
201 assertEquals("tmpContext has wrong timestamp after first seekEvent()",contextValueAfterFirstEvent
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
202 assertNotSame("tmpEvent is null after seekEvent() to start ",null,tmpEvent
);
203 assertTrue("tmpEvent has wrong reference after seekEvent() to start", firstEventReference
.contains(tmpEvent
.getReference()));
206 public void testSeekLocation() {
207 TmfEvent tmpEvent
= null;
208 ITmfContext tmpContext
= new TmfContext(null, 0);
209 final LTTngTrace testStream1
= prepareStreamToTest();
211 // We should be at the beginning of the trace, we will seek at a certain timestamp
212 tmpContext
= testStream1
.seekEvent(new LttngLocation(locationToSeekTest1
));
213 tmpEvent
= testStream1
.getNext(tmpContext
);
214 assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext
);
215 assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekTest1
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
216 assertNotSame("tmpEvent is null after first seekLocation()",null,tmpEvent
);
217 assertTrue("tmpEvent has wrong reference after first seekLocation()", seek1EventReference
.contains(tmpEvent
.getReference()));
219 // Seek to the last timestamp
220 tmpContext
= testStream1
.seekEvent(new LttngLocation(locationToSeekLast
));
221 tmpEvent
= testStream1
.getNext(tmpContext
);
222 assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext
);
223 assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterSeekLast
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
224 assertNotSame("tmpEvent is null after seekLocation() to last ",null,tmpEvent
);
225 assertTrue("tmpEvent has wrong reference after seekLocation() to last", seekLastEventReference
.contains(tmpEvent
.getReference()));
227 // Seek to the first timestamp (startTime)
228 tmpContext
= testStream1
.seekEvent(new LttngLocation(locationToSeekFirst
));
229 tmpEvent
= testStream1
.getNext(tmpContext
);
230 assertNotSame("tmpContext is null after first seekLocation()",null,tmpContext
);
231 assertEquals("tmpContext has wrong timestamp after first seekLocation()",contextValueAfterFirstEvent
,((TmfTimestamp
)tmpEvent
.getTimestamp()).getValue() );
232 assertNotSame("tmpEvent is null after seekLocation() to start ",null,tmpEvent
);
233 assertTrue("tmpEvent has wrong reference after seekLocation() to start", firstEventReference
.contains(tmpEvent
.getReference()));
236 public void testLocationOperations() {
237 TmfEvent tmpEvent
= null;
238 ITmfContext tmpContext
= new TmfContext(null, 0);
239 final LTTngTrace testStream1
= prepareStreamToTest();
241 // Test LttngLocation after a seek
242 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
243 LttngLocation location
= (LttngLocation
) tmpContext
.getLocation().clone();
244 assertTrue("location has wrong flag", location
.isLastOperationSeek());
245 assertEquals("location has wrong operation time", seekTimestamp
, location
.getOperationTimeValue());
246 tmpContext
= testStream1
.seekEvent(location
);
247 tmpEvent
= testStream1
.getNext(tmpContext
);
248 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
249 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
251 // Test LttngLocation after a parse
252 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
253 tmpEvent
= testStream
.parseEvent(tmpContext
);
254 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
255 location
= (LttngLocation
) tmpContext
.getLocation().clone();
256 assertTrue("location has wrong flag", location
.isLastOperationParse());
257 assertEquals("location has wrong operation time", seekTimestamp
, location
.getOperationTimeValue());
258 tmpContext
= testStream1
.seekEvent(location
);
259 tmpEvent
= testStream1
.getNext(tmpContext
);
260 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
261 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
263 // Test LttngLocation after a getNext
264 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
265 tmpEvent
= testStream
.getNext(tmpContext
);
266 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
267 location
= (LttngLocation
) tmpContext
.getLocation().clone();
268 assertTrue("location has wrong flag", location
.isLastOperationReadNext());
269 assertEquals("location has wrong operation time", seekTimestamp
, location
.getOperationTimeValue());
270 tmpContext
= testStream1
.seekEvent(location
);
271 tmpEvent
= testStream1
.getNext(tmpContext
);
272 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
273 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
275 // Test LttngLocation after a parse and parse
276 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
277 tmpEvent
= testStream
.parseEvent(tmpContext
);
278 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
279 tmpEvent
= testStream
.parseEvent(tmpContext
);
280 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
281 location
= (LttngLocation
) tmpContext
.getLocation().clone();
282 assertTrue("location has wrong flag", location
.isLastOperationParse());
283 assertEquals("location has wrong operation time", seekTimestamp
, location
.getOperationTimeValue());
284 tmpContext
= testStream1
.seekEvent(location
);
285 tmpEvent
= testStream1
.getNext(tmpContext
);
286 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
287 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
289 // Test LttngLocation after a getNext and getNext
290 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
291 tmpEvent
= testStream
.getNext(tmpContext
);
292 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
293 tmpEvent
= testStream
.getNext(tmpContext
);
294 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
295 location
= (LttngLocation
) tmpContext
.getLocation().clone();
296 assertTrue("location has wrong flag", location
.isLastOperationReadNext());
297 assertEquals("location has wrong operation time", nextEventTimestamp
, location
.getOperationTimeValue());
298 tmpContext
= testStream1
.seekEvent(location
);
299 tmpEvent
= testStream1
.getNext(tmpContext
);
300 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
301 assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
303 // Test LttngLocation after a getNext and parse
304 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
305 tmpEvent
= testStream
.getNext(tmpContext
);
306 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
307 tmpEvent
= testStream
.parseEvent(tmpContext
);
308 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
309 location
= (LttngLocation
) tmpContext
.getLocation().clone();
310 assertTrue("location has wrong flag", location
.isLastOperationParse());
311 assertEquals("location has wrong operation time", nextEventTimestamp
, location
.getOperationTimeValue());
312 tmpContext
= testStream1
.seekEvent(location
);
313 tmpEvent
= testStream1
.getNext(tmpContext
);
314 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
315 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
317 // Test LttngLocation after a parse and getNext
318 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
319 tmpEvent
= testStream
.parseEvent(tmpContext
);
320 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
321 tmpEvent
= testStream
.getNext(tmpContext
);
322 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
323 location
= (LttngLocation
) tmpContext
.getLocation().clone();
324 assertTrue("location has wrong flag", location
.isLastOperationReadNext());
325 assertEquals("location has wrong operation time", seekTimestamp
, location
.getOperationTimeValue());
326 tmpContext
= testStream1
.seekEvent(location
);
327 tmpEvent
= testStream1
.getNext(tmpContext
);
328 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
329 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
331 // Test LttngLocation after a parse, getNext and parse
332 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
333 tmpEvent
= testStream
.parseEvent(tmpContext
);
334 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
335 tmpEvent
= testStream
.getNext(tmpContext
);
336 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
337 tmpEvent
= testStream
.parseEvent(tmpContext
);
338 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
339 location
= (LttngLocation
) tmpContext
.getLocation().clone();
340 assertTrue("location has wrong flag", location
.isLastOperationParse());
341 assertEquals("location has wrong operation time", nextEventTimestamp
, location
.getOperationTimeValue());
342 tmpContext
= testStream1
.seekEvent(location
);
343 tmpEvent
= testStream1
.getNext(tmpContext
);
344 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
345 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
347 // Test LttngLocation after a parse, getNext and getNext
348 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
349 tmpEvent
= testStream
.parseEvent(tmpContext
);
350 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
351 tmpEvent
= testStream
.getNext(tmpContext
);
352 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
353 tmpEvent
= testStream
.getNext(tmpContext
);
354 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
355 location
= (LttngLocation
) tmpContext
.getLocation().clone();
356 assertTrue("location has wrong flag", location
.isLastOperationReadNext());
357 assertEquals("location has wrong operation time", nextEventTimestamp
, location
.getOperationTimeValue());
358 tmpContext
= testStream1
.seekEvent(location
);
359 tmpEvent
= testStream1
.getNext(tmpContext
);
360 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
361 assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
363 // Test LttngLocation after a getNext, parse and parse
364 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
365 tmpEvent
= testStream
.getNext(tmpContext
);
366 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
367 tmpEvent
= testStream
.parseEvent(tmpContext
);
368 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
369 tmpEvent
= testStream
.parseEvent(tmpContext
);
370 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
371 location
= (LttngLocation
) tmpContext
.getLocation().clone();
372 assertTrue("location has wrong flag", location
.isLastOperationParse());
373 assertEquals("location has wrong operation time", nextEventTimestamp
, location
.getOperationTimeValue());
374 tmpContext
= testStream1
.seekEvent(location
);
375 tmpEvent
= testStream1
.getNext(tmpContext
);
376 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
377 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
379 // Test LttngLocation after a getNext, parse and getNext
380 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
381 tmpEvent
= testStream
.getNext(tmpContext
);
382 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
383 tmpEvent
= testStream
.parseEvent(tmpContext
);
384 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
385 tmpEvent
= testStream
.getNext(tmpContext
);
386 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
387 location
= (LttngLocation
) tmpContext
.getLocation().clone();
388 assertTrue("location has wrong flag", location
.isLastOperationReadNext());
389 assertEquals("location has wrong operation time", nextEventTimestamp
, location
.getOperationTimeValue());
390 tmpContext
= testStream1
.seekEvent(location
);
391 tmpEvent
= testStream1
.getNext(tmpContext
);
392 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
393 assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
395 // Test LttngLocation after a getNext, getNext and parse
396 tmpContext
= testStream1
.seekEvent(new LttngLocation(seekTimestamp
));
397 tmpEvent
= testStream
.getNext(tmpContext
);
398 assertEquals("tmpEvent has wrong timestamp", seekTimestamp
, tmpEvent
.getTimestamp().getValue());
399 tmpEvent
= testStream
.getNext(tmpContext
);
400 assertEquals("tmpEvent has wrong timestamp", nextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
401 tmpEvent
= testStream
.parseEvent(tmpContext
);
402 assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
403 location
= (LttngLocation
) tmpContext
.getLocation().clone();
404 assertTrue("location has wrong flag", location
.isLastOperationParse());
405 assertEquals("location has wrong operation time", nextnextEventTimestamp
, location
.getOperationTimeValue());
406 tmpContext
= testStream1
.seekEvent(location
);
407 tmpEvent
= testStream1
.getNext(tmpContext
);
408 assertTrue("tmpContext is null after getNextEvent()", tmpEvent
!= null);
409 assertEquals("tmpEvent has wrong timestamp", nextnextEventTimestamp
, tmpEvent
.getTimestamp().getValue());
412 public void testGetter() {
413 TmfEvent tmpEvent
= null;
414 final LTTngTrace testStream1
= prepareStreamToTest();
416 // Move to the first event to have something to play with
417 tmpEvent
= testStream1
.parseEvent( new TmfContext(null, 0));
419 // Test current event
420 assertNotSame("tmpEvent is null after first event",null,tmpEvent
);
421 assertTrue("tmpEvent has wrong reference after first event", firstEventReference
.contains(tmpEvent
.getReference()));
422 assertNotSame("tmpContext is null after first seekEvent()",null,testStream1
.getCurrentLocation() );
423 assertTrue("tmpContext has wrong timestamp after first seekEvent()",locationAfterFirstEvent
.equals( ((LttngLocation
)testStream1
.getCurrentLocation()).getOperationTimeValue()) );
425 // Test CPU number of the trace
426 assertSame("getCpuNumber() return wrong number of cpu",traceCpuNumber
,testStream1
.getCpuNumber() );
429 public void testToString() {
430 final LTTngTrace testStream1
= prepareStreamToTest();
432 // Move to the first event to have something to play with
433 testStream1
.parseEvent( new TmfContext(null, 0) );
435 // Just make sure toString() does not return null or the java reference
436 assertNotSame("toString returned null",null, testStream1
.toString() );
437 assertNotSame("toString is not overridded!", testStream1
.getClass().getName() + '@' + Integer
.toHexString(testStream1
.hashCode()), testStream1
.toString() );