235af47150fcfa5b424ba304a9c3e7f51dfa342d
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.core.tests / src / org / eclipse / tracecompass / analysis / os / linux / core / tests / latency / SyscallStatsAnalysisTest.java
1 /*******************************************************************************
2 * Copyright (c) 2015 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 static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14
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;
27
28 /**
29 * Tests for the system call statistics analysis
30 *
31 * @author Matthew Khouzam
32 */
33 public class SyscallStatsAnalysisTest {
34
35 private TmfTrace fTestTrace;
36 private SystemCallLatencyStatisticsAnalysisModule fSyscallStatsModule;
37
38 /**
39 * Create the fixtures
40 */
41 @Before
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)) {
48 module = mod;
49 }
50 assertNotNull(module);
51 module.schedule();
52 module.waitForCompletion();
53 SystemCallLatencyStatisticsAnalysisModule syscallStatsModule = null;
54 for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, SystemCallLatencyStatisticsAnalysisModule.class)) {
55 syscallStatsModule = (SystemCallLatencyStatisticsAnalysisModule) mod;
56 }
57 assertNotNull(syscallStatsModule);
58 syscallStatsModule.schedule();
59 syscallStatsModule.waitForCompletion();
60 fSyscallStatsModule = syscallStatsModule;
61 }
62
63 /**
64 * Dispose everything
65 */
66 @After
67 public void cleanup() {
68 final TmfTrace testTrace = fTestTrace;
69 if (testTrace != null) {
70 testTrace.dispose();
71 }
72 }
73
74 /**
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
77 */
78 @Test
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());
86 }
87 }
This page took 0.034921 seconds and 4 git commands to generate.