Commit | Line | Data |
---|---|---|
ff71e543 MK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2014 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Matthew Khouzam - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
7ce90559 | 13 | package org.eclipse.tracecompass.btf.core.tests.utils; |
ff71e543 | 14 | |
7ce90559 | 15 | import org.eclipse.tracecompass.btf.core.trace.BtfTrace; |
2bdf0193 AM |
16 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
17 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; | |
18 | import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; | |
ff71e543 MK |
19 | |
20 | /** | |
21 | * Helpers for testing the btf trace. There is a main() top run the code without | |
22 | * eclipse (for educational purposes) and an event printer | |
23 | * | |
24 | * @author Matthew Khouzam | |
25 | */ | |
26 | public class TestBtfTrace { | |
27 | ||
28 | /** | |
29 | * Test | |
30 | * | |
31 | * @param args | |
32 | * nothing | |
33 | * @throws TmfTraceException | |
34 | * exception | |
35 | */ | |
36 | public static void main(String[] args) throws TmfTraceException { | |
d9aa847c AM |
37 | BtfTrace trace = new BtfTrace(); |
38 | trace.initTrace(null, BtfTestTrace.BTF_TEST.getFullPath(), null); | |
39 | System.out.println(trace.toString()); | |
40 | ||
41 | ITmfContext ctx = trace.seekEvent(0); | |
42 | ITmfContext ctx1 = trace.seekEvent(10); | |
43 | ITmfEvent event = trace.getNext(ctx); | |
44 | ITmfEvent compare = null; | |
45 | while (event != null) { | |
46 | if (event.getRank() == 10) { | |
47 | compare = event; | |
ff71e543 | 48 | } |
d9aa847c AM |
49 | printEvent(event); |
50 | event = trace.getNext(ctx); | |
ff71e543 | 51 | } |
d9aa847c AM |
52 | ITmfEvent other = trace.getNext(ctx1); |
53 | printEvent(other); | |
54 | printEvent(compare); | |
55 | ||
56 | trace.dispose(); | |
ff71e543 MK |
57 | } |
58 | ||
59 | private static void printEvent(ITmfEvent event) { | |
60 | if (event == null) { | |
61 | System.out.println("null"); | |
62 | } else { | |
578716e6 | 63 | System.out.println(event.getRank() + " " + event.getTimestamp().getValue() + " " + event.getName() + " " + event.getContent().toString()); |
ff71e543 MK |
64 | } |
65 | } | |
66 | ||
67 | } |