File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
affinity/src/test/java/net/openhft/affinity Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ package net .openhft .affinity ;
2
+
3
+ import net .openhft .affinity .impl .VanillaCpuLayout ;
4
+ import org .junit .Test ;
5
+
6
+ import java .io .File ;
7
+
8
+ import static org .junit .Assert .assertEquals ;
9
+
10
+ public class AffinityResetToBaseAffinityTest extends BaseAffinityTest {
11
+
12
+ @ Test
13
+ public void resettingShouldRestoreBaseAffinity () throws Exception {
14
+ if (!new File ("/proc/cpuinfo" ).exists ()) {
15
+ System .out .println ("Cannot run affinity test as this system doesn't have a /proc/cpuinfo file" );
16
+ return ;
17
+ }
18
+
19
+ // initialise CPU layout from the running machine so acquireLock works
20
+ AffinityLock .cpuLayout (VanillaCpuLayout .fromCpuInfo ());
21
+
22
+ assertEquals (AffinityLock .BASE_AFFINITY , Affinity .getAffinity ());
23
+ AffinityLock lock = AffinityLock .acquireLock ();
24
+ try {
25
+ assertEquals (1 , Affinity .getAffinity ().cardinality ());
26
+
27
+ Affinity .resetToBaseAffinity ();
28
+ assertEquals (AffinityLock .BASE_AFFINITY , Affinity .getAffinity ());
29
+ } finally {
30
+ lock .release ();
31
+ }
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments