os.linux: Make KernelCtfTraceStub public
[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.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;
28
29 /**
30 * Tests for the system call statistics analysis
31 *
32 * @author Matthew Khouzam
33 */
34 public class SyscallStatsAnalysisTest {
35
36 private TmfTrace fTestTrace;
37 private SystemCallLatencyStatisticsAnalysisModule fSyscallStatsModule;
38
39 /**
40 * Create the fixtures
41 */
42 @Before
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)) {
49 module = mod;
50 }
51 assertNotNull(module);
52 module.schedule();
53 module.waitForCompletion();
54 SystemCallLatencyStatisticsAnalysisModule syscallStatsModule = null;
55 for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, SystemCallLatencyStatisticsAnalysisModule.class)) {
56 syscallStatsModule = (SystemCallLatencyStatisticsAnalysisModule) mod;
57 }
58 assertNotNull(syscallStatsModule);
59 syscallStatsModule.schedule();
60 syscallStatsModule.waitForCompletion();
61 fSyscallStatsModule = syscallStatsModule;
62 }
63
64 /**
65 * Dispose everything
66 */
67 @After
68 public void cleanup() {
69 final TmfTrace testTrace = fTestTrace;
70 if (testTrace != null) {
71 testTrace.dispose();
72 }
73 }
74
75 /**
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
78 */
79 @Test
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());
87 }
88 }
This page took 0.031547 seconds and 5 git commands to generate.