1 /*******************************************************************************
2 * Copyright (c) 2015 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 org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.tests
.stubs
.trace
.KernelCtfTraceStub
;
16 import org
.eclipse
.tracecompass
.analysis
.timing
.core
.segmentstore
.statistics
.SegmentStoreStatistics
;
17 import org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.core
.latency
.SystemCallLatencyAnalysis
;
18 import org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.core
.latency
.statistics
.SystemCallLatencyStatisticsAnalysisModule
;
19 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.IAnalysisModule
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTrace
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceUtils
;
25 import org
.junit
.After
;
26 import org
.junit
.Before
;
27 import org
.junit
.Test
;
30 * Tests for the system call statistics analysis
32 * @author Matthew Khouzam
34 public class SyscallStatsAnalysisTest
{
36 private TmfTrace fTestTrace
;
37 private SystemCallLatencyStatisticsAnalysisModule fSyscallStatsModule
;
43 public void setupAnalysis() {
44 ITmfTrace trace
= KernelCtfTraceStub
.getTrace(CtfTestTrace
.ARM_64_BIT_HEADER
);
45 /* Make sure the Kernel analysis has run */
46 ((TmfTrace
) trace
).traceOpened(new TmfTraceOpenedSignal(this, trace
, null));
47 IAnalysisModule module
= null;
48 for (IAnalysisModule mod
: TmfTraceUtils
.getAnalysisModulesOfClass(trace
, SystemCallLatencyAnalysis
.class)) {
51 assertNotNull(module
);
53 module
.waitForCompletion();
54 SystemCallLatencyStatisticsAnalysisModule syscallStatsModule
= null;
55 for (IAnalysisModule mod
: TmfTraceUtils
.getAnalysisModulesOfClass(trace
, SystemCallLatencyStatisticsAnalysisModule
.class)) {
56 syscallStatsModule
= (SystemCallLatencyStatisticsAnalysisModule
) mod
;
58 assertNotNull(syscallStatsModule
);
59 syscallStatsModule
.schedule();
60 syscallStatsModule
.waitForCompletion();
61 fSyscallStatsModule
= syscallStatsModule
;
68 public void cleanup() {
69 final TmfTrace testTrace
= fTestTrace
;
70 if (testTrace
!= null) {
76 * This will load the analysis and test it. as it depends on Kernel, this
77 * test runs the kernel trace first then the analysis
80 public void testSmallTraceSequential() {
81 final SystemCallLatencyStatisticsAnalysisModule syscallStatsModule
= fSyscallStatsModule
;
82 assertNotNull(syscallStatsModule
);
83 SegmentStoreStatistics totalStats
= syscallStatsModule
.getTotalStats();
84 assertNotNull(totalStats
);
85 assertEquals(1801, totalStats
.getNbSegments());
86 assertEquals(5904091700L, totalStats
.getMax());