Commit | Line | Data |
---|---|---|
53e5d2d3 GM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2014 École Polytechnique de Montréal | |
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 | * Contributors: | |
10 | * Guilliano Molaire - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
9bc60be7 | 13 | package org.eclipse.tracecompass.lttng2.ust.core.tests.analysis.memory; |
53e5d2d3 GM |
14 | |
15 | import static org.junit.Assert.assertEquals; | |
16 | import static org.junit.Assert.assertNotNull; | |
17 | import static org.junit.Assert.assertTrue; | |
18 | ||
19 | import java.util.Set; | |
20 | ||
116738ad | 21 | import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory.UstMemoryStrings; |
9bc60be7 AM |
22 | import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings; |
23 | import org.eclipse.tracecompass.lttng2.ust.core.analysis.memory.UstMemoryAnalysisModule; | |
2bdf0193 | 24 | import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement; |
53e5d2d3 GM |
25 | import org.junit.Before; |
26 | import org.junit.Test; | |
27 | ||
28 | import com.google.common.collect.ImmutableSet; | |
29 | ||
30 | /** | |
31 | * Tests for the {@link UstMemoryAnalysisModule} | |
32 | * | |
33 | * @author Guilliano Molaire | |
34 | */ | |
35 | public class UstMemoryAnalysisModuleTest { | |
36 | ||
37 | /** The analysis module */ | |
38 | private UstMemoryAnalysisModule fUstAnalysisModule; | |
39 | ||
40 | /** | |
41 | * Set-up the test | |
42 | */ | |
43 | @Before | |
44 | public void setup() { | |
45 | fUstAnalysisModule = new UstMemoryAnalysisModule(); | |
46 | } | |
47 | ||
48 | /** | |
49 | * Test for {@link UstMemoryAnalysisModule#getAnalysisRequirements()} | |
50 | */ | |
51 | @Test | |
52 | public void testGetAnalysisRequirements() { | |
53 | Iterable<TmfAnalysisRequirement> requirements = fUstAnalysisModule.getAnalysisRequirements(); | |
54 | assertNotNull(requirements); | |
55 | assertTrue(requirements.iterator().hasNext()); | |
56 | ||
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; | |
67 | } | |
68 | } | |
69 | assertNotNull(eventReq); | |
70 | assertNotNull(domainReq); | |
71 | ||
72 | /* There should be two requirements */ | |
73 | assertEquals(2, numberOfRequirement); | |
74 | ||
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); | |
80 | } | |
81 | ||
82 | /* Events */ | |
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 | |
90 | ); | |
91 | ||
92 | assertEquals(6, eventReq.getValues().size()); | |
93 | for (String event : eventReq.getValues()) { | |
94 | assertTrue("Unexpected event " + event, expectedEvents.contains(event)); | |
95 | } | |
96 | ||
97 | Set<String> infos = eventReq.getInformation(); | |
98 | assertEquals(2, infos.size()); | |
99 | } | |
100 | ||
101 | } |