1 /*******************************************************************************
2 * Copyright (c) 2016 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
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.tests
.latency
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertNotNull
;
15 import java
.io
.IOException
;
17 import org
.eclipse
.core
.runtime
.FileLocator
;
18 import org
.eclipse
.jdt
.annotation
.NonNull
;
19 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.latency
.SystemCallLatencyAnalysis
;
20 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.tests
.stubs
.trace
.KernelEventLayoutStub
;
21 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.trace
.IKernelAnalysisEventLayout
;
22 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.trace
.IKernelTrace
;
23 import org
.eclipse
.tracecompass
.segmentstore
.core
.ISegment
;
24 import org
.eclipse
.tracecompass
.segmentstore
.core
.ISegmentStore
;
25 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.IAnalysisModule
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfTraceException
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTrace
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceUtils
;
32 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEvent
;
33 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
34 import org
.junit
.After
;
35 import org
.junit
.Before
;
36 import org
.junit
.Test
;
39 * Tests for the system call analysis
41 * @author Matthew Khouzam
43 public class SyscallAnalysisTest
{
45 private static class KernelStubTrace
extends CtfTmfTrace
implements IKernelTrace
{
46 public KernelStubTrace() {
50 public static synchronized KernelStubTrace
getTrace(CtfTestTrace ctfTrace
) {
53 tracePath
= FileLocator
.toFileURL(ctfTrace
.getTraceURL()).getPath();
54 } catch (IOException e
) {
55 throw new IllegalStateException();
58 KernelStubTrace trace
= new KernelStubTrace();
60 trace
.initTrace(null, tracePath
, CtfTmfEvent
.class);
61 } catch (TmfTraceException e
) {
62 /* Should not happen if tracesExist() passed */
63 throw new RuntimeException(e
);
69 public @NonNull IKernelAnalysisEventLayout
getKernelEventLayout() {
70 return KernelEventLayoutStub
.getInstance();
74 private SystemCallLatencyAnalysis fSyscallModule
;
81 ITmfTrace trace
= KernelStubTrace
.getTrace(CtfTestTrace
.ARM_64_BIT_HEADER
);
82 /* Make sure the Kernel analysis has run */
83 ((TmfTrace
) trace
).traceOpened(new TmfTraceOpenedSignal(this, trace
, null));
84 for (IAnalysisModule mod
: TmfTraceUtils
.getAnalysisModulesOfClass(trace
, SystemCallLatencyAnalysis
.class)) {
85 fSyscallModule
= (SystemCallLatencyAnalysis
) mod
;
87 assertNotNull(fSyscallModule
);
88 fSyscallModule
.schedule();
89 fSyscallModule
.waitForCompletion();
96 public void cleanup() {
97 final SystemCallLatencyAnalysis syscallModule
= fSyscallModule
;
98 if( syscallModule
!= null) {
99 syscallModule
.dispose();
104 * This will load the analysis and test it. as it depends on Kernel, this
105 * test runs the kernel trace first then the analysis
108 public void testSmallTraceSequential() {
109 final SystemCallLatencyAnalysis syscallModule
= fSyscallModule
;
110 assertNotNull(syscallModule
);
111 ISegmentStore
<@NonNull ISegment
> segmentStore
= syscallModule
.getSegmentStore();
112 assertNotNull(segmentStore
);
113 assertEquals(1801, segmentStore
.size());