Commit | Line | Data |
---|---|---|
d0043318 GB |
1 | /******************************************************************************* |
2 | * Copyright (c) 2016 É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 | package org.eclipse.tracecompass.analysis.os.linux.core.tests.inputoutput; | |
10 | ||
11 | import static org.junit.Assert.assertEquals; | |
12 | ||
13 | import java.util.Arrays; | |
14 | import java.util.Collection; | |
15 | ||
16 | import org.eclipse.jdt.annotation.NonNull; | |
17 | import org.eclipse.tracecompass.analysis.os.linux.core.inputoutput.Disk; | |
18 | import org.eclipse.tracecompass.analysis.os.linux.core.inputoutput.InputOutputAnalysisModule; | |
19 | import org.eclipse.tracecompass.analysis.os.linux.core.inputoutput.InputOutputInformationProvider; | |
20 | import org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.LinuxTestCase; | |
21 | import org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.inputoutput.IoTestFactory; | |
22 | import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestHelper; | |
23 | import org.junit.After; | |
24 | import org.junit.Test; | |
25 | import org.junit.runner.RunWith; | |
26 | import org.junit.runners.Parameterized; | |
27 | import org.junit.runners.Parameterized.Parameters; | |
28 | ||
29 | /** | |
30 | * Test the {@link InputOutputInformationProvider} class | |
31 | * | |
32 | * @author Geneviève Bastien | |
33 | */ | |
34 | @RunWith(Parameterized.class) | |
35 | public class InputOutputInformationProviderTest extends AbstractTestInputOutput { | |
36 | ||
37 | private final LinuxTestCase fTestCase; | |
38 | private final int fDiskCount; | |
39 | ||
40 | /** | |
41 | * Constructor | |
42 | * | |
43 | * @param testName | |
44 | * A name for the test, to display in the header | |
45 | * @param test | |
46 | * A test case parameter for this test | |
47 | * @param diskCount | |
48 | * The number of disks | |
49 | */ | |
50 | public InputOutputInformationProviderTest(String testName, LinuxTestCase test, int diskCount) { | |
51 | super(); | |
52 | fTestCase = test; | |
53 | fDiskCount = diskCount; | |
54 | } | |
55 | ||
56 | /** | |
57 | * Clean up | |
58 | */ | |
59 | @After | |
60 | public void tearDown() { | |
61 | super.deleteTrace(); | |
62 | } | |
63 | ||
64 | @Override | |
65 | protected @NonNull InputOutputAnalysisModule setUp(String fileName) { | |
66 | InputOutputAnalysisModule module = super.setUp(fileName); | |
67 | TmfTestHelper.executeAnalysis(module); | |
68 | return module; | |
69 | } | |
70 | ||
71 | /** | |
72 | * @return The arrays of parameters | |
73 | */ | |
74 | @Parameters(name = "{index}: {0}") | |
75 | public static Iterable<Object[]> getParameters() { | |
76 | return Arrays.asList(new Object[][] { | |
77 | { IoTestFactory.SIMPLE_REQUESTS.getTraceFileName(), IoTestFactory.SIMPLE_REQUESTS, 1 }, | |
78 | { IoTestFactory.SIMPLE_NO_STATEDUMP.getTraceFileName(), IoTestFactory.SIMPLE_NO_STATEDUMP, 1 }, | |
79 | { IoTestFactory.TWO_DEVICES.getTraceFileName(), IoTestFactory.TWO_DEVICES, 3 } | |
80 | }); | |
81 | } | |
82 | ||
83 | /** | |
84 | * Test the | |
85 | * {@link InputOutputInformationProvider#getDisks(InputOutputAnalysisModule)} | |
86 | * method | |
87 | */ | |
88 | @Test | |
89 | public void testGetDisks() { | |
90 | InputOutputAnalysisModule module = setUp(fTestCase.getTraceFileName()); | |
91 | Collection<Disk> disks = InputOutputInformationProvider.getDisks(module); | |
92 | assertEquals(fDiskCount, disks.size()); | |
93 | } | |
94 | ||
95 | } |