Skip to content

Commit

Permalink
[GR-35330] Make assertion more robust to avoid transients.
Browse files Browse the repository at this point in the history
PullRequest: graal/10472
  • Loading branch information
chumer committed Dec 5, 2021
2 parents 63ce319 + 95dd6fc commit 408cf22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,16 @@ public void testTimeout() throws InterruptedException {
"CALL(sample))",

}, (samples, i) -> {
if (i == 0) {
assertEquals(1, samples.size());
Iterator<StackTraceEntry> iterator = samples.values().iterator().next().iterator();
// first time we are in sample
assertEntry(iterator, "sample", 14);
assertEntry(iterator, "", 0);
assertFalse(iterator.hasNext());
} else {
// assert in or after first sample call, but never in second sample
if (samples.size() > 0) {
List<StackTraceEntry> entries = samples.values().iterator().next();
Iterator<StackTraceEntry> iterator = entries.iterator();
if (entries.size() == 2) {
assertEntry(iterator, "sample", 14);
assertEntry(iterator, "", 0);
assertFalse(iterator.hasNext());
} else {
assertEntry(iterator, "", 0);
assertFalse(iterator.hasNext());
}
if (samples.size() > 0) {
List<StackTraceEntry> entries = samples.values().iterator().next();
Iterator<StackTraceEntry> iterator = entries.iterator();
if (entries.size() == 2) {
assertEntry(iterator, "sample", 14);
assertEntry(iterator, "", 0);
assertFalse(iterator.hasNext());
} else {
assertEntry(iterator, "", 0);
assertFalse(iterator.hasNext());
}
}
}, 2, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private static Future<?> submitThreadLocalInternal(Env env, Thread[] threads, Th
public void testEnterSlowPathFallback() throws ExecutionException, InterruptedException {
ExecutorService executorService = Executors.newFixedThreadPool(1);
try {
for (int itNo = 0; itNo < 10000; itNo++) {
for (int itNo = 0; itNo < 1000; itNo++) {
CountDownLatch enterLeaveLoopLatch = new CountDownLatch(1);
AtomicReference<Env> envAtomicReference = new AtomicReference<>();
AtomicReference<Context> contextAtomicReference = new AtomicReference<>();
Expand All @@ -248,7 +248,7 @@ public void testEnterSlowPathFallback() throws ExecutionException, InterruptedEx
enterLeaveLoopLatch.countDown();
TruffleContext truffleContext = envAtomicReference.get().getContext();
try {
for (int i = 0; i < 1000000; i++) {
for (int i = 0; i < 100000; i++) {
Object prev = truffleContext.enter(INVALID_NODE);
truffleContext.leave(INVALID_NODE, prev);
}
Expand Down

0 comments on commit 408cf22

Please sign in to comment.