Loading ravenwood/common-src/com/android/ravenwood/common/RavenwoodInternalUtils.java +29 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.function.Supplier; import java.util.regex.Pattern; public class RavenwoodInternalUtils { public static final String TAG = "Ravenwood"; Loading Loading @@ -270,4 +271,32 @@ public class RavenwoodInternalUtils { public static <T> T withDefault(@Nullable T value, @Nullable T def) { return value != null ? value : def; } private static final Pattern sWildcardValidater = Pattern.compile("[^\\w.*$]"); /** * Convert a wildcard string using "*" and "**" to match Java classnames. * * The input string can only contain alnum, "$", "." and "*". */ public static Pattern parseClassNameWildcard(String pattern) { // Convert "**" -> match anything (== .*) // Convert "*" -> match anything except for periods (== [^.]*) // Convert "." -> \. if (sWildcardValidater.matcher(pattern).find()) { throw new IllegalArgumentException( "Invalid character found in wildcard '" + pattern + "'"); } // Save "**" to something else and convert it back to ".*" at the end. String temp = pattern.replace("**", "@@"); temp = temp.replace(".", "\\."); temp = temp.replace("$", "\\$"); temp = temp.replace("*", "[^.]*"); temp = temp.replace("@@", ".*"); return Pattern.compile(temp); } } ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunner.java +3 −3 Original line number Diff line number Diff line Loading @@ -118,7 +118,7 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase * * We need to do it before instantiating TestClass for b/367694651. */ if (!RavenwoodEnablementChecker.shouldRunClassOnRavenwood(testClass, true)) { if (!RavenwoodEnablementChecker.getInstance().shouldRunClassOnRavenwood(testClass)) { mRealRunner = new ClassSkippingTestRunner(testClass); return; } Loading Loading @@ -244,7 +244,7 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase private boolean mFilteredOut; ClassSkippingTestRunner(Class<?> testClass) { mDescription = Description.createTestDescription(testClass, testClass.getSimpleName()); mDescription = Description.createTestDescription(testClass, "<init>"); mFilteredOut = false; } Loading Loading @@ -288,7 +288,7 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase // Class-level annotations are checked by the runner already, so we only check // method-level annotations here. if (scope == Scope.Instance && order == Order.Outer) { if (!RavenwoodEnablementChecker.shouldEnableOnRavenwood(description, true)) { if (!RavenwoodEnablementChecker.getInstance().shouldEnableOnRavenwood(description)) { return false; } } Loading ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodDriver.java +8 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.util.Log_ravenwood; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.RuntimeInit; import com.android.ravenwood.OpenJdkWorkaround; import com.android.ravenwood.RavenwoodRuntimeNative; import com.android.ravenwood.common.RavenwoodInternalUtils; import com.android.ravenwood.common.SneakyThrow; Loading Loading @@ -263,6 +264,13 @@ public class RavenwoodDriver { // TODO(b/428775903) Make sure nothing would try to access compat-IDs before this call. // We may want to do it within initAppDriver(). initializeCompatIds(); // `pkill -USR2 -f tradefed-isolation.jar` will interrupt the test thread. final Thread testThread = Thread.currentThread(); OpenJdkWorkaround.registerSignalHandler("USR2", () -> { sRawStdErr.println("-----SIGUSR2 HANDLER-----"); testThread.interrupt(); }); } /** Loading ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodEnablementChecker.java +491 −189 File changed.Preview size limit exceeded, changes collapsed. Show changes ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodEnvironment.java +12 −0 Original line number Diff line number Diff line Loading @@ -367,4 +367,16 @@ public final class RavenwoodEnvironment { public boolean getBoolEnvVar(String keyName) { return "1".equals(getEnvVar(keyName, "")); } /** * Reads a per-module environmental string variable, and split it with whitespace. * Default is an empty array; */ public String[] getArrayEnvVar(String keyName) { var val = getEnvVar(keyName, ""); if (val.isEmpty()) { return new String[0]; } return val.split("\\s+"); } } Loading
ravenwood/common-src/com/android/ravenwood/common/RavenwoodInternalUtils.java +29 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.function.Supplier; import java.util.regex.Pattern; public class RavenwoodInternalUtils { public static final String TAG = "Ravenwood"; Loading Loading @@ -270,4 +271,32 @@ public class RavenwoodInternalUtils { public static <T> T withDefault(@Nullable T value, @Nullable T def) { return value != null ? value : def; } private static final Pattern sWildcardValidater = Pattern.compile("[^\\w.*$]"); /** * Convert a wildcard string using "*" and "**" to match Java classnames. * * The input string can only contain alnum, "$", "." and "*". */ public static Pattern parseClassNameWildcard(String pattern) { // Convert "**" -> match anything (== .*) // Convert "*" -> match anything except for periods (== [^.]*) // Convert "." -> \. if (sWildcardValidater.matcher(pattern).find()) { throw new IllegalArgumentException( "Invalid character found in wildcard '" + pattern + "'"); } // Save "**" to something else and convert it back to ".*" at the end. String temp = pattern.replace("**", "@@"); temp = temp.replace(".", "\\."); temp = temp.replace("$", "\\$"); temp = temp.replace("*", "[^.]*"); temp = temp.replace("@@", ".*"); return Pattern.compile(temp); } }
ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunner.java +3 −3 Original line number Diff line number Diff line Loading @@ -118,7 +118,7 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase * * We need to do it before instantiating TestClass for b/367694651. */ if (!RavenwoodEnablementChecker.shouldRunClassOnRavenwood(testClass, true)) { if (!RavenwoodEnablementChecker.getInstance().shouldRunClassOnRavenwood(testClass)) { mRealRunner = new ClassSkippingTestRunner(testClass); return; } Loading Loading @@ -244,7 +244,7 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase private boolean mFilteredOut; ClassSkippingTestRunner(Class<?> testClass) { mDescription = Description.createTestDescription(testClass, testClass.getSimpleName()); mDescription = Description.createTestDescription(testClass, "<init>"); mFilteredOut = false; } Loading Loading @@ -288,7 +288,7 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase // Class-level annotations are checked by the runner already, so we only check // method-level annotations here. if (scope == Scope.Instance && order == Order.Outer) { if (!RavenwoodEnablementChecker.shouldEnableOnRavenwood(description, true)) { if (!RavenwoodEnablementChecker.getInstance().shouldEnableOnRavenwood(description)) { return false; } } Loading
ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodDriver.java +8 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.util.Log_ravenwood; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.RuntimeInit; import com.android.ravenwood.OpenJdkWorkaround; import com.android.ravenwood.RavenwoodRuntimeNative; import com.android.ravenwood.common.RavenwoodInternalUtils; import com.android.ravenwood.common.SneakyThrow; Loading Loading @@ -263,6 +264,13 @@ public class RavenwoodDriver { // TODO(b/428775903) Make sure nothing would try to access compat-IDs before this call. // We may want to do it within initAppDriver(). initializeCompatIds(); // `pkill -USR2 -f tradefed-isolation.jar` will interrupt the test thread. final Thread testThread = Thread.currentThread(); OpenJdkWorkaround.registerSignalHandler("USR2", () -> { sRawStdErr.println("-----SIGUSR2 HANDLER-----"); testThread.interrupt(); }); } /** Loading
ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodEnablementChecker.java +491 −189 File changed.Preview size limit exceeded, changes collapsed. Show changes
ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodEnvironment.java +12 −0 Original line number Diff line number Diff line Loading @@ -367,4 +367,16 @@ public final class RavenwoodEnvironment { public boolean getBoolEnvVar(String keyName) { return "1".equals(getEnvVar(keyName, "")); } /** * Reads a per-module environmental string variable, and split it with whitespace. * Default is an empty array; */ public String[] getArrayEnvVar(String keyName) { var val = getEnvVar(keyName, ""); if (val.isEmpty()) { return new String[0]; } return val.split("\\s+"); } }