1 /*******************************************************************************
2 * Copyright (c) 2014 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 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.tracecompass
.btf
.core
.tests
.trace
;
14 import static org
.junit
.Assert
.*;
18 import org
.eclipse
.tracecompass
.btf
.core
.tests
.utils
.BtfTestTrace
;
19 import org
.eclipse
.tracecompass
.btf
.core
.trace
.BtfTrace
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfContext
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TraceValidationStatus
;
23 import org
.junit
.After
;
24 import org
.junit
.Before
;
25 import org
.junit
.Test
;
28 * Best trace format test cases
30 * @author Matthew Khouzam
32 public class BtfTraceTest
{
34 private static final long START_TIME
= 1392809960000000000L;
36 private BtfTrace fixture
;
39 * Does the trace exist?
43 fixture
= BtfTestTrace
.BTF_TEST
.getTrace();
44 assertNotNull(fixture
);
51 public void cleanup() {
59 public void testValidate(){
60 TraceValidationStatus status
= (TraceValidationStatus
) fixture
.validate(null, fixture
.getPath());
61 assertNotNull(status
);
62 assertTrue(status
.isOK());
63 assertEquals(100, status
.getConfidence());
68 * Seek the first event
71 public void testSeek1stEvent() {
72 ITmfContext ctx
= fixture
.seekEvent(0);
74 assertEquals(0, ctx
.getRank());
75 assertEquals(499L, ctx
.getLocation().getLocationInfo());
79 * Read the first event
82 public void testRead1stEvent() {
83 ITmfContext ctx
= fixture
.seekEvent(0);
84 ITmfEvent event
= fixture
.getNext(ctx
);
86 assertEquals(START_TIME
, event
.getTimestamp().getValue());
90 * Read the tenth event
93 public void testRead10thEvent1() {
94 ITmfContext ctx
= fixture
.seekEvent(10);
95 ITmfEvent event
= fixture
.getNext(ctx
);
97 assertEquals(START_TIME
, event
.getTimestamp().getValue());
101 * Read the tenth event without seeking
104 public void testRead10thEvent2() {
105 ITmfContext ctx
= fixture
.seekEvent(0);
106 ITmfEvent event
= null;
107 for (int i
= 0; i
< 10; i
++) {
108 event
= fixture
.getNext(ctx
);
110 assertNotNull(event
);
111 assertEquals(START_TIME
, event
.getTimestamp().getValue());
115 * Read the trace properties
118 public void testReadProperties() {
119 Map
<String
, String
> data
= fixture
.getTraceProperties();
121 assertEquals("ns", data
.get("#timeScale"));
122 assertEquals("2.1.0", data
.get("#version"));
129 public void testTwoContexts() {
130 ITmfContext ctx0
= fixture
.seekEvent(0);
131 ITmfContext ctx1
= fixture
.seekEvent(10);
132 ITmfEvent event
= null;
133 for (int i
= 0; i
< 11; i
++) {
134 event
= fixture
.getNext(ctx0
);
136 ITmfEvent event1
= fixture
.getNext(ctx1
);
137 assertNotNull(event
);
138 assertNotNull(event1
);
139 assertEquals(event
, event1
);