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 | ||
10 | package org.eclipse.tracecompass.analysis.os.linux.core.tests.latency; | |
11 | ||
12 | import java.io.IOException; | |
13 | ||
14 | import org.eclipse.core.runtime.FileLocator; | |
15 | import org.eclipse.jdt.annotation.NonNull; | |
16 | import org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.KernelEventLayoutStub; | |
17 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout; | |
18 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace; | |
19 | import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace; | |
20 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; | |
21 | import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; | |
22 | import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; | |
23 | ||
24 | class KernelCtfTraceStub extends CtfTmfTrace implements IKernelTrace { | |
25 | public KernelCtfTraceStub() { | |
26 | super(); | |
27 | } | |
28 | ||
29 | public static synchronized KernelCtfTraceStub getTrace(CtfTestTrace ctfTrace) { | |
30 | String tracePath; | |
31 | try { | |
32 | tracePath = FileLocator.toFileURL(ctfTrace.getTraceURL()).getPath(); | |
33 | } catch (IOException e) { | |
34 | throw new IllegalStateException(); | |
35 | } | |
36 | ||
37 | KernelCtfTraceStub trace = new KernelCtfTraceStub(); | |
38 | try { | |
39 | trace.initTrace(null, tracePath, CtfTmfEvent.class); | |
40 | } catch (TmfTraceException e) { | |
41 | /* Should not happen if tracesExist() passed */ | |
42 | throw new RuntimeException(e); | |
43 | } | |
44 | return trace; | |
45 | } | |
46 | ||
47 | @Override | |
48 | public @NonNull IKernelAnalysisEventLayout getKernelEventLayout() { | |
49 | return KernelEventLayoutStub.getInstance(); | |
50 | } | |
51 | } |