Skip to content

Add test for non-binding lock affinity #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions affinity/src/test/java/net/openhft/affinity/AffinityLockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.BitSet;

import static net.openhft.affinity.AffinityLock.PROCESSORS;
import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -319,6 +320,16 @@ public void testAffinityLockDescriptions() {
}
}

@Test
public void acquireLockWithoutBindingDoesNotChangeAffinity() {
BitSet before = (BitSet) Affinity.getAffinity().clone();
try (AffinityLock lock = AffinityLock.acquireLock(false)) {
assertFalse(lock.isBound());
assertEquals(before, Affinity.getAffinity());
}
assertEquals(before, Affinity.getAffinity());
}

@Test(expected = IllegalArgumentException.class)
public void testTooHighCpuId() {
AffinityLock.acquireLock(123456);
Expand Down