1 /*******************************************************************************
2 * Copyright (c) 2014 É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 * Guilliano Molaire - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng2
.ust
.core
.tests
.analysis
.memory
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.assertTrue
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ust
.core
.memoryusage
.UstMemoryStrings
;
22 import org
.eclipse
.linuxtools
.lttng2
.control
.core
.session
.SessionConfigStrings
;
23 import org
.eclipse
.linuxtools
.lttng2
.ust
.core
.analysis
.memory
.UstMemoryAnalysisModule
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.analysis
.TmfAnalysisRequirement
;
25 import org
.junit
.Before
;
26 import org
.junit
.Test
;
28 import com
.google
.common
.collect
.ImmutableSet
;
31 * Tests for the {@link UstMemoryAnalysisModule}
33 * @author Guilliano Molaire
35 public class UstMemoryAnalysisModuleTest
{
37 /** The analysis module */
38 private UstMemoryAnalysisModule fUstAnalysisModule
;
45 fUstAnalysisModule
= new UstMemoryAnalysisModule();
49 * Test for {@link UstMemoryAnalysisModule#getAnalysisRequirements()}
52 public void testGetAnalysisRequirements() {
53 Iterable
<TmfAnalysisRequirement
> requirements
= fUstAnalysisModule
.getAnalysisRequirements();
54 assertNotNull(requirements
);
55 assertTrue(requirements
.iterator().hasNext());
57 /* There should be the event and domain type */
58 TmfAnalysisRequirement eventReq
= null;
59 TmfAnalysisRequirement domainReq
= null;
60 int numberOfRequirement
= 0;
61 for (TmfAnalysisRequirement requirement
: requirements
) {
62 ++numberOfRequirement
;
63 if (requirement
.getType().equals(SessionConfigStrings
.CONFIG_ELEMENT_EVENT
)) {
64 eventReq
= requirement
;
65 } else if (requirement
.getType().equals(SessionConfigStrings
.CONFIG_ELEMENT_DOMAIN
)) {
66 domainReq
= requirement
;
69 assertNotNull(eventReq
);
70 assertNotNull(domainReq
);
72 /* There should be two requirements */
73 assertEquals(2, numberOfRequirement
);
75 /* Verify the content of the requirements themselves */
76 /* Domain should be kernel */
77 assertEquals(1, domainReq
.getValues().size());
78 for (String domain
: domainReq
.getValues()) {
79 assertEquals(SessionConfigStrings
.CONFIG_DOMAIN_TYPE_UST
, domain
);
83 Set
<String
> expectedEvents
= ImmutableSet
.of(
84 UstMemoryStrings
.MALLOC
,
85 UstMemoryStrings
.FREE
,
86 UstMemoryStrings
.CALLOC
,
87 UstMemoryStrings
.REALLOC
,
88 UstMemoryStrings
.MEMALIGN
,
89 UstMemoryStrings
.POSIX_MEMALIGN
92 assertEquals(6, eventReq
.getValues().size());
93 for (String event
: eventReq
.getValues()) {
94 assertTrue("Unexpected event " + event
, expectedEvents
.contains(event
));
97 Set
<String
> infos
= eventReq
.getInformation();
98 assertEquals(2, infos
.size());