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
.assertEquals
;
15 import static org
.junit
.Assert
.assertNotNull
;
16 import static org
.junit
.Assert
.assertTrue
;
20 import org
.eclipse
.tracecompass
.btf
.core
.tests
.utils
.BtfTestTrace
;
21 import org
.eclipse
.tracecompass
.btf
.core
.trace
.BtfTrace
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfContext
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TraceValidationStatus
;
25 import org
.junit
.After
;
26 import org
.junit
.Before
;
27 import org
.junit
.Test
;
30 * Best trace format test cases
32 * @author Matthew Khouzam
34 public class BtfTraceTest
{
36 private static final long START_TIME
= 1392809960000000000L;
38 private BtfTrace fixture
;
41 * Does the trace exist?
45 fixture
= BtfTestTrace
.BTF_TEST
.getTrace();
46 assertNotNull(fixture
);
53 public void cleanup() {
61 public void testValidate(){
62 TraceValidationStatus status
= (TraceValidationStatus
) fixture
.validate(null, fixture
.getPath());
63 assertNotNull(status
);
64 assertTrue(status
.isOK());
65 assertEquals(100, status
.getConfidence());
70 * Seek the first event
73 public void testSeek1stEvent() {
74 ITmfContext ctx
= fixture
.seekEvent(0);
76 assertEquals(0, ctx
.getRank());
77 assertEquals(499L, ctx
.getLocation().getLocationInfo());
81 * Read the first event
84 public void testRead1stEvent() {
85 ITmfContext ctx
= fixture
.seekEvent(0);
86 ITmfEvent event
= fixture
.getNext(ctx
);
88 assertEquals(START_TIME
, event
.getTimestamp().getValue());
92 * Read the tenth event
95 public void testRead10thEvent1() {
96 ITmfContext ctx
= fixture
.seekEvent(10);
97 ITmfEvent event
= fixture
.getNext(ctx
);
99 assertEquals(START_TIME
, event
.getTimestamp().getValue());
103 * Read the tenth event without seeking
106 public void testRead10thEvent2() {
107 ITmfContext ctx
= fixture
.seekEvent(0);
108 ITmfEvent event
= null;
109 for (int i
= 0; i
< 10; i
++) {
110 event
= fixture
.getNext(ctx
);
112 assertNotNull(event
);
113 assertEquals(START_TIME
, event
.getTimestamp().getValue());
117 * Read the trace properties
120 public void testReadProperties() {
121 Map
<String
, String
> data
= fixture
.getProperties();
123 assertEquals("ns", data
.get("#timeScale"));
124 assertEquals("2.1.0", data
.get("#version"));
131 public void testTwoContexts() {
132 ITmfContext ctx0
= fixture
.seekEvent(0);
133 ITmfContext ctx1
= fixture
.seekEvent(10);
134 ITmfEvent event
= null;
135 for (int i
= 0; i
< 11; i
++) {
136 event
= fixture
.getNext(ctx0
);
138 ITmfEvent event1
= fixture
.getNext(ctx1
);
139 assertNotNull(event
);
140 assertNotNull(event1
);
141 assertEquals(event
, event1
);