Skip to content

Commit 722978b

Browse files
Merge pull request #174 from OpenHFT/codex/build-vanillacpulayout-and-assert-pair(i)
Add VanillaCpuLayout pair() tests
2 parents e59a667 + 931075d commit 722978b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2016-2025 chronicle.software
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.openhft.affinity.impl;
18+
19+
import org.junit.Test;
20+
21+
import java.io.IOException;
22+
import java.io.InputStream;
23+
24+
import static org.junit.Assert.assertEquals;
25+
26+
/**
27+
* Tests for {@link VanillaCpuLayout#pair(int)} using sample cpuinfo files.
28+
*/
29+
public class VanillaCpuLayoutPairTest {
30+
31+
@Test
32+
public void testPairForI7() throws IOException {
33+
try (InputStream is = getClass().getClassLoader().getResourceAsStream("i7.cpuinfo")) {
34+
VanillaCpuLayout layout = VanillaCpuLayout.fromCpuInfo(is);
35+
assertEquals(4, layout.pair(0));
36+
assertEquals(5, layout.pair(1));
37+
assertEquals(6, layout.pair(2));
38+
assertEquals(7, layout.pair(3));
39+
assertEquals(0, layout.pair(4));
40+
assertEquals(1, layout.pair(5));
41+
assertEquals(2, layout.pair(6));
42+
assertEquals(3, layout.pair(7));
43+
}
44+
}
45+
46+
@Test
47+
public void testPairForI3() throws IOException {
48+
try (InputStream is = getClass().getClassLoader().getResourceAsStream("i3.cpuinfo")) {
49+
VanillaCpuLayout layout = VanillaCpuLayout.fromCpuInfo(is);
50+
assertEquals(2, layout.pair(0));
51+
assertEquals(3, layout.pair(1));
52+
assertEquals(0, layout.pair(2));
53+
assertEquals(1, layout.pair(3));
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)