common: Generalize the BufferedBlockingQueue's concurrent test
[deliverable/tracecompass.git] / org.eclipse.tracecompass.btf.core.tests / src / org / eclipse / tracecompass / btf / core / tests / utils / TestBtfTrace.java
CommitLineData
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 13package org.eclipse.tracecompass.btf.core.tests.utils;
ff71e543
MK
14
15import java.io.IOException;
16
7ce90559 17import org.eclipse.tracecompass.btf.core.trace.BtfTrace;
2bdf0193
AM
18import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
19import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
20import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
ff71e543
MK
21
22/**
23 * Helpers for testing the btf trace. There is a main() top run the code without
24 * eclipse (for educational purposes) and an event printer
25 *
26 * @author Matthew Khouzam
27 */
28public class TestBtfTrace {
29
30 /**
31 * Test
32 *
33 * @param args
34 * nothing
35 * @throws TmfTraceException
36 * exception
37 */
38 public static void main(String[] args) throws TmfTraceException {
39 try (BtfTrace trace = new BtfTrace()) {
40 trace.initTrace(null, BtfTestTrace.BTF_TEST.getFullPath(), null);
41 System.out.println(trace.toString());
42 ITmfContext ctx = trace.seekEvent(0);
43 ITmfContext ctx1 = trace.seekEvent(10);
44 ITmfEvent event = trace.getNext(ctx);
45 ITmfEvent compare = null;
46 while (event != null) {
47 if (event.getRank() == 10) {
48 compare = event;
49 }
50 printEvent(event);
51 event = trace.getNext(ctx);
52 }
53 ITmfEvent other = trace.getNext(ctx1);
54 printEvent(other);
55 printEvent(compare);
56 } catch (IOException e) {
57 e.printStackTrace();
58 }
59 }
60
61 private static void printEvent(ITmfEvent event) {
62 if (event == null) {
63 System.out.println("null");
64 } else {
578716e6 65 System.out.println(event.getRank() + " " + event.getTimestamp().getValue() + " " + event.getName() + " " + event.getContent().toString());
ff71e543
MK
66 }
67 }
68
69}
This page took 0.06387 seconds and 5 git commands to generate.