Commit | Line | Data |
---|---|---|
3a676d86 MK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2016 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 | ||
4bf167e7 | 10 | package org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace; |
3a676d86 MK |
11 | |
12 | import java.io.IOException; | |
13 | ||
14 | import org.eclipse.core.runtime.FileLocator; | |
15 | import org.eclipse.jdt.annotation.NonNull; | |
3a676d86 MK |
16 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout; |
17 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace; | |
18 | import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace; | |
19 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; | |
20 | import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; | |
21 | import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; | |
22 | ||
4bf167e7 AM |
23 | /** |
24 | * Stub for a generic CTF kernel trace. | |
25 | * | |
26 | * It's basically an LTTng (2.0/2.1) trace, but without depending on o.e.t.lttng2.kernel! | |
27 | */ | |
28 | public class KernelCtfTraceStub extends CtfTmfTrace implements IKernelTrace { | |
29 | ||
30 | /** | |
31 | * Constructor | |
32 | */ | |
3a676d86 MK |
33 | public KernelCtfTraceStub() { |
34 | super(); | |
35 | } | |
36 | ||
4bf167e7 AM |
37 | /** |
38 | * Get a trace from a CTF test trace. | |
39 | * | |
40 | * @param ctfTrace | |
41 | * The CTF test trace | |
42 | * @return The initialized trace | |
43 | */ | |
3a676d86 MK |
44 | public static synchronized KernelCtfTraceStub getTrace(CtfTestTrace ctfTrace) { |
45 | String tracePath; | |
46 | try { | |
47 | tracePath = FileLocator.toFileURL(ctfTrace.getTraceURL()).getPath(); | |
48 | } catch (IOException e) { | |
49 | throw new IllegalStateException(); | |
50 | } | |
51 | ||
52 | KernelCtfTraceStub trace = new KernelCtfTraceStub(); | |
53 | try { | |
54 | trace.initTrace(null, tracePath, CtfTmfEvent.class); | |
55 | } catch (TmfTraceException e) { | |
56 | /* Should not happen if tracesExist() passed */ | |
57 | throw new RuntimeException(e); | |
58 | } | |
59 | return trace; | |
60 | } | |
61 | ||
62 | @Override | |
63 | public @NonNull IKernelAnalysisEventLayout getKernelEventLayout() { | |
64 | return KernelEventLayoutStub.getInstance(); | |
65 | } | |
66 | } |