You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2023/12/18 11:38:36 UTC

(lucene) branch branch_9x updated: An improved check for ignoring the c2-crash test if running on a client compiler. (#12953)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 41794f0957e An improved check for ignoring the c2-crash test if running on a client compiler. (#12953)
41794f0957e is described below

commit 41794f0957e382783548fca996446ec005e0ce64
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Mon Dec 18 12:37:57 2023 +0100

    An improved check for ignoring the c2-crash test if running on a client compiler. (#12953)
---
 gradle/testing/randomization/policies/tests.policy      |  3 ---
 .../org/apache/lucene/util/bkd/TestDocIdsWriter.java    | 17 +++++------------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/gradle/testing/randomization/policies/tests.policy b/gradle/testing/randomization/policies/tests.policy
index 5bfba952776..8a56ab1d1b7 100644
--- a/gradle/testing/randomization/policies/tests.policy
+++ b/gradle/testing/randomization/policies/tests.policy
@@ -63,9 +63,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";
 
diff --git a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java
index 6ddcabb03ae..086eb460e56 100644
--- a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java
@@ -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;
@@ -34,7 +32,7 @@ import org.apache.lucene.store.IndexOutput;
 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 {
 
@@ -159,10 +157,12 @@ public class TestDocIdsWriter extends LuceneTestCase {
   }
 
   // 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();
@@ -174,11 +174,4 @@ public class TestDocIdsWriter extends LuceneTestCase {
       }
     }
   }
-
-  @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);
-  }
 }