diff options
| author | 2024-09-10 11:20:40 -0700 | |
|---|---|---|
| committer | 2024-09-10 11:25:02 -0700 | |
| commit | c317d4a270f9d0cd50f9fd307f31a3f8d92fe26a (patch) | |
| tree | 16162af7b7bebb23ebe631bad3b52127e702516b | |
| parent | e3323b7d911f401033919743a16ba2c3c77ae7e3 (diff) | |
Allow junit-impl to see runtime-helper-src
Flag: EXEMPT host test change only
Bug: 292141694
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh
Change-Id: If540b852eaf0dec6b47e94553000444ef533b5ec
3 files changed, 13 insertions, 33 deletions
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp index eebe5e9fc054..8ff99e4af30d 100644 --- a/ravenwood/Android.bp +++ b/ravenwood/Android.bp @@ -129,9 +129,9 @@ java_library { ], libs: [ "framework-minus-apex.ravenwood", - "ravenwood-junit", "ravenwood-helper-libcore-runtime", ], + sdk_version: "core_current", visibility: ["//visibility:private"], } @@ -165,6 +165,8 @@ java_library { "services.core.ravenwood", "junit", "framework-annotations-lib", + "ravenwood-helper-framework-runtime", + "ravenwood-helper-libcore-runtime", ], sdk_version: "core_current", visibility: ["//frameworks/base"], diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java index 92a1cb7fc3bf..68472c12a568 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java @@ -28,6 +28,7 @@ import android.util.Log; import androidx.test.platform.app.InstrumentationRegistry; import com.android.internal.os.RuntimeInit; +import com.android.platform.test.ravenwood.runtimehelper.ClassLoadHook; import com.android.ravenwood.common.RavenwoodCommonUtils; import org.junit.runner.Description; @@ -75,6 +76,9 @@ public class RavenwoodAwareTestRunnerHook { // We haven't initialized liblog yet, so directly write to System.out here. RavenwoodCommonUtils.log(TAG, "initOnce()"); + // Make sure libandroid_runtime is loaded. + ClassLoadHook.onClassLoaded(Log.class); + // Redirect stdout/stdin to liblog. RuntimeInit.redirectLogStreams(); @@ -82,6 +86,10 @@ public class RavenwoodAwareTestRunnerHook { System.setProperty("android.junit.runner", "androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner"); System.setProperty(RAVENWOOD_VERSION_JAVA_SYSPROP, "1"); + + // Do the basic set up for the android sysprops. + RavenwoodRuntimeEnvironmentController.setSystemProperties( + RavenwoodSystemProperties.DEFAULT_VALUES); } /** diff --git a/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java b/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java index 3bf116da19b8..e12ff240c4d9 100644 --- a/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java +++ b/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java @@ -15,21 +15,10 @@ */ package com.android.internal.ravenwood; -import android.os.SystemProperties_host; -import android.platform.test.ravenwood.RavenwoodSystemProperties; -import android.util.Log; - import com.android.ravenwood.common.JvmWorkaround; import com.android.ravenwood.common.RavenwoodCommonUtils; public class RavenwoodEnvironment_host { - private static final String TAG = RavenwoodEnvironment.TAG; - - private static final Object sInitializeLock = new Object(); - - // @GuardedBy("sInitializeLock") - private static boolean sInitialized; - private RavenwoodEnvironment_host() { } @@ -37,27 +26,8 @@ public class RavenwoodEnvironment_host { * Called from {@link RavenwoodEnvironment#ensureRavenwoodInitialized()}. */ public static void ensureRavenwoodInitialized() { - - // TODO Unify it with the initialization code in RavenwoodAwareTestRunnerHook. - - synchronized (sInitializeLock) { - if (sInitialized) { - return; - } - Log.i(TAG, "Initializing Ravenwood environment"); - - // Set the default values. - var sysProps = RavenwoodSystemProperties.DEFAULT_VALUES; - - // We have a method that does it in RavenwoodRuleImpl, but we can't use that class - // here, So just inline it. - SystemProperties_host.initializeIfNeeded( - sysProps.getValues(), - sysProps.getKeyReadablePredicate(), - sysProps.getKeyWritablePredicate()); - - sInitialized = true; - } + // Initialization is now done by RavenwoodAwareTestRunner. + // Should we remove it? } /** |