diff options
author | 2024-05-16 15:44:38 -0700 | |
---|---|---|
committer | 2024-05-20 09:37:06 -0700 | |
commit | 5b1f7008ab8d985b7292eecb7a1e47e2c10031fb (patch) | |
tree | a490023391776f463a6dd9d85697692594091945 /ravenwood/junit-src | |
parent | 976da2d6a1a414dd8752bdd06eb26b81d3291dee (diff) |
[Ravenwood] Internal clean up, more PFD APIs, OsConstants, etc
- Support a few more ParcelFileDescriptor APIs.
- Support OsConstants and a couple of Os APIs.
- Also clean up f/b/ravenwood. Now we have "runtime-common" library
that can be used from different components of Ravenwood infra,
with native code support.
Bug: 292141694
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh
Test: CtsOsTestCases (on tree hugger)
Change-Id: Ia06873114e80e9dd309d2cf077b208aaa7396542
Diffstat (limited to 'ravenwood/junit-src')
-rw-r--r-- | ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java | 4 | ||||
-rw-r--r-- | ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java | 94 |
2 files changed, 5 insertions, 93 deletions
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java index 9d12f855c0ea..68b5aebe9c00 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java @@ -29,6 +29,8 @@ import android.platform.test.annotations.DisabledOnRavenwood; import android.platform.test.annotations.EnabledOnRavenwood; import android.platform.test.annotations.IgnoreUnderRavenwood; +import com.android.ravenwood.common.RavenwoodCommonUtils; + import org.junit.Assume; import org.junit.rules.TestRule; import org.junit.runner.Description; @@ -54,7 +56,7 @@ import java.util.regex.Pattern; * before a test class is fully initialized. */ public class RavenwoodRule implements TestRule { - static final boolean IS_ON_RAVENWOOD = RavenwoodRuleImpl.isOnRavenwood(); + static final boolean IS_ON_RAVENWOOD = RavenwoodCommonUtils.isOnRavenwood(); /** * When probing is enabled, all tests will be unconditionally run on Ravenwood to detect diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java index 99ab32788235..19c1bffaebcd 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodUtils.java @@ -15,9 +15,7 @@ */ package android.platform.test.ravenwood; -import java.io.File; -import java.io.PrintStream; -import java.util.Arrays; +import com.android.ravenwood.common.RavenwoodCommonUtils; /** * Utilities for writing (bivalent) ravenwood tests. @@ -26,15 +24,6 @@ public class RavenwoodUtils { private RavenwoodUtils() { } - private static final String RAVENWOOD_NATIVE_RUNTIME_NAME = "ravenwood_runtime"; - - // LibcoreRavenwoodUtils calls it with reflections. - public static void loadRavenwoodNativeRuntime() { - if (RavenwoodRule.isOnRavenwood()) { - RavenwoodUtils.loadJniLibrary(RAVENWOOD_NATIVE_RUNTIME_NAME); - } - } - /** * Load a JNI library respecting {@code java.library.path} * (which reflects {@code LD_LIBRARY_PATH}). @@ -56,85 +45,6 @@ public class RavenwoodUtils { * it uses {@code JNI_OnLoad()} as the entry point name on both. */ public static void loadJniLibrary(String libname) { - if (RavenwoodRule.isOnRavenwood()) { - loadLibraryOnRavenwood(libname); - } else { - // Just delegate to the loadLibrary(). - System.loadLibrary(libname); - } - } - - private static void loadLibraryOnRavenwood(String libname) { - var path = System.getProperty("java.library.path"); - var filename = "lib" + libname + ".so"; - - System.out.println("Looking for library " + libname + ".so in java.library.path:" + path); - - try { - if (path == null) { - throw new UnsatisfiedLinkError("Cannot load library " + libname + "." - + " Property java.library.path not set!"); - } - for (var dir : path.split(":")) { - var file = new File(dir + "/" + filename); - if (file.exists()) { - System.load(file.getAbsolutePath()); - return; - } - } - throw new UnsatisfiedLinkError("Library " + libname + " not found in " - + "java.library.path: " + path); - } catch (Throwable e) { - dumpFiles(System.out); - throw e; - } - } - - private static void dumpFiles(PrintStream out) { - try { - var path = System.getProperty("java.library.path"); - out.println("# java.library.path=" + path); - - for (var dir : path.split(":")) { - listFiles(out, new File(dir), ""); - - var gparent = new File((new File(dir)).getAbsolutePath() + "../../..") - .getCanonicalFile(); - if (gparent.getName().contains("testcases")) { - // Special case: if we found this directory, dump its contents too. - listFiles(out, gparent, ""); - } - } - - var gparent = new File("../..").getCanonicalFile(); - out.println("# ../..=" + gparent); - listFiles(out, gparent, ""); - } catch (Throwable th) { - out.println("Error: " + th.toString()); - th.printStackTrace(out); - } - } - - private static void listFiles(PrintStream out, File dir, String prefix) { - if (!dir.isDirectory()) { - out.println(prefix + dir.getAbsolutePath() + " is not a directory!"); - return; - } - out.println(prefix + ":" + dir.getAbsolutePath() + "/"); - // First, list the files. - for (var file : Arrays.stream(dir.listFiles()).sorted().toList()) { - out.println(prefix + " " + file.getName() + "" + (file.isDirectory() ? "/" : "")); - } - - // Then recurse. - if (dir.getAbsolutePath().startsWith("/usr") || dir.getAbsolutePath().startsWith("/lib")) { - // There would be too many files, so don't recurse. - return; - } - for (var file : Arrays.stream(dir.listFiles()).sorted().toList()) { - if (file.isDirectory()) { - listFiles(out, file, prefix + " "); - } - } + RavenwoodCommonUtils.loadJniLibrary(libname); } } |