Skip to content

Commit 473d058

Browse files
Merge pull request #167 from OpenHFT/codex/verify-affinity-unchanged-after-lock-acquisition
Add test for non-binding lock affinity
2 parents 6e1c12c + 3e8ed8e commit 473d058

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

affinity/src/test/java/net/openhft/affinity/AffinityLockTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.nio.file.Paths;
3232
import java.util.ArrayList;
3333
import java.util.List;
34+
import java.util.BitSet;
3435

3536
import static net.openhft.affinity.AffinityLock.PROCESSORS;
3637
import static org.hamcrest.CoreMatchers.is;
@@ -319,6 +320,16 @@ public void testAffinityLockDescriptions() {
319320
}
320321
}
321322

323+
@Test
324+
public void acquireLockWithoutBindingDoesNotChangeAffinity() {
325+
BitSet before = (BitSet) Affinity.getAffinity().clone();
326+
try (AffinityLock lock = AffinityLock.acquireLock(false)) {
327+
assertFalse(lock.isBound());
328+
assertEquals(before, Affinity.getAffinity());
329+
}
330+
assertEquals(before, Affinity.getAffinity());
331+
}
332+
322333
@Test(expected = IllegalArgumentException.class)
323334
public void testTooHighCpuId() {
324335
AffinityLock.acquireLock(123456);

0 commit comments

Comments
 (0)