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