Skip to content
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

An improved check for ignoring the c2-crash test if running on a client compiler. #12953

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions gradle/testing/randomization/policies/tests.policy
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ grant {
permission java.lang.RuntimePermission "getFileStoreAttributes";
permission java.lang.RuntimePermission "writeFileDescriptor";

// needed to check if C2 (implied by the presence of the CI env) is enabled
permission java.lang.RuntimePermission "getenv.CI";

// TestLockFactoriesMultiJVM opens a random port on 127.0.0.1 (port 0 = ephemeral port range):
permission java.net.SocketPermission "127.0.0.1:0", "accept,listen,resolve";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package org.apache.lucene.util.bkd;

import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
Expand All @@ -34,7 +32,7 @@
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.CollectionUtil;
import org.apache.lucene.util.SuppressForbidden;
import org.apache.lucene.util.Constants;

public class TestDocIdsWriter extends LuceneTestCase {

Expand Down Expand Up @@ -159,10 +157,12 @@ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
}

// This simple test tickles a JVM C2 JIT crash on JDK's less than 21.0.1
// Crashes only when run with C2, so with the environment variable `CI` set
// Crashes only when run with HotSpot C2.
// Regardless of whether C2 is enabled or not, the test should never fail.
public void testCrash() throws IOException {
assumeTrue("Requires C2, which is only enabled when CI env is set", getCIEnv() != null);
assumeTrue(
"Requires HotSpot C2 compiler (won't work on client VM).",
Constants.IS_HOTSPOT_VM && !Constants.IS_CLIENT_VM);
int itrs = atLeast(100);
for (int i = 0; i < itrs; i++) {
try (Directory dir = newDirectory();
Expand All @@ -174,11 +174,4 @@ public void testCrash() throws IOException {
}
}
}

@SuppressForbidden(reason = "needed to check if C2 is enabled")
@SuppressWarnings("removal")
private static String getCIEnv() {
PrivilegedAction<String> pa = () -> System.getenv("CI");
return AccessController.doPrivileged(pa);
}
}