1
2
3
4
5 package oshi.driver.windows;
6
7 import static org.hamcrest.MatcherAssert.assertThat;
8 import static org.hamcrest.Matchers.empty;
9 import static org.hamcrest.Matchers.greaterThanOrEqualTo;
10 import static org.hamcrest.Matchers.is;
11 import static org.hamcrest.Matchers.not;
12 import static org.hamcrest.Matchers.nullValue;
13
14 import java.util.List;
15
16 import org.junit.jupiter.api.Test;
17 import org.junit.jupiter.api.condition.EnabledOnOs;
18 import org.junit.jupiter.api.condition.OS;
19
20 import oshi.hardware.CentralProcessor.LogicalProcessor;
21 import oshi.hardware.CentralProcessor.PhysicalProcessor;
22 import oshi.hardware.CentralProcessor.ProcessorCache;
23 import oshi.util.tuples.Triplet;
24
25 @EnabledOnOs(OS.WINDOWS)
26 class LogicalProcessorInformationTest {
27 @Test
28 void testGetLogicalProcessorInformation() {
29 Triplet<List<LogicalProcessor>, List<PhysicalProcessor>, List<ProcessorCache>> info = LogicalProcessorInformation
30 .getLogicalProcessorInformation();
31 assertThat("Logical Processor list must not be empty", info.getA(), is(not(empty())));
32 assertThat("Physical Processor list is null", info.getB(), is(nullValue()));
33 assertThat("Cache list is null", info.getC(), is(nullValue()));
34 }
35
36 @Test
37 void testGetLogicalProcessorInformationEx() {
38 Triplet<List<LogicalProcessor>, List<PhysicalProcessor>, List<ProcessorCache>> info = LogicalProcessorInformation
39 .getLogicalProcessorInformationEx();
40 assertThat("Must be more Logical Processors than Physical Ones", info.getA().size(),
41 greaterThanOrEqualTo(info.getB().size()));
42 assertThat("Must be more Physical Processors than L3 Caches", info.getB().size(),
43 greaterThanOrEqualTo((int) info.getC().stream().filter(c -> c.getLevel() == 3).count()));
44 assertThat("Must be more Physical Processors than L2 Caches", info.getB().size(),
45 greaterThanOrEqualTo((int) info.getC().stream().filter(c -> c.getLevel() == 2).count()));
46 }
47 }