1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 École Polytechnique de Montréal
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
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.tests
.analysis
.kernel
;
15 import static org
.junit
.Assert
.assertFalse
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.assertNull
;
18 import static org
.junit
.Assert
.assertTrue
;
19 import static org
.junit
.Assert
.fail
;
21 import java
.util
.List
;
23 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernel
.KernelAnalysisModule
;
24 import org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.trace
.LttngKernelTrace
;
25 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystem
;
26 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfTraceException
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.tests
.shared
.TmfTestHelper
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
31 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEvent
;
32 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTraceUtils
;
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 * Test the {@link KernelAnalysisModule} class
41 * @author Geneviève Bastien
43 public class LttngKernelAnalysisTest
{
45 private LttngKernelTrace fTrace
;
46 private KernelAnalysisModule fKernelAnalysisModule
;
53 fKernelAnalysisModule
= new KernelAnalysisModule();
54 // Rework the utils to allow creating a sub-type directly.
55 String path
= CtfTmfTestTraceUtils
.getTrace(CtfTestTrace
.KERNEL
).getPath();
57 fTrace
= new LttngKernelTrace();
59 fTrace
.initTrace(null, path
, CtfTmfEvent
.class);
60 } catch (TmfTraceException e
) {
61 /* Should not happen if tracesExist() passed */
62 throw new RuntimeException(e
);
67 * Dispose test objects
70 public void tearDown() {
72 fKernelAnalysisModule
.dispose();
74 fKernelAnalysisModule
= null;
78 * Test the LTTng kernel analysis execution
81 public void testAnalysisExecution() {
82 fKernelAnalysisModule
.setId("test");
83 ITmfTrace trace
= fTrace
;
86 assertTrue(fKernelAnalysisModule
.setTrace(trace
));
87 } catch (TmfAnalysisException e
) {
90 // Assert the state system has not been initialized yet
91 ITmfStateSystem ss
= fKernelAnalysisModule
.getStateSystem();
94 assertTrue(TmfTestHelper
.executeAnalysis(fKernelAnalysisModule
));
96 ss
= fKernelAnalysisModule
.getStateSystem();
99 List
<Integer
> quarks
= ss
.getQuarks("*");
100 assertFalse(quarks
.isEmpty());
104 * Test the canExecute method on valid and invalid traces
107 public void testCanExecute() {
108 /* Test with a valid kernel trace */
109 assertNotNull(fTrace
);
110 assertTrue(fKernelAnalysisModule
.canExecute(fTrace
));
112 /* Test with a CTF trace that does not have required events */
113 CtfTmfTrace trace
= CtfTmfTestTraceUtils
.getTrace(CtfTestTrace
.CYG_PROFILE
);
115 * TODO: This should be false, but for now there is no mandatory events
116 * in the kernel analysis so it will return true.
118 assertTrue(fKernelAnalysisModule
.canExecute(trace
));