Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2baa179b authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Pass "ravenwood-runtime" path from tradefed" into main

parents a976c42a 70fffccb
Loading
Loading
Loading
Loading
+13 −31
Original line number Original line Diff line number Diff line
@@ -48,8 +48,11 @@ public class RavenwoodCommonUtils {
    public static final boolean RAVENWOOD_VERBOSE_LOGGING = "1".equals(System.getenv(
    public static final boolean RAVENWOOD_VERBOSE_LOGGING = "1".equals(System.getenv(
            "RAVENWOOD_VERBOSE"));
            "RAVENWOOD_VERBOSE"));


    /** Directory name of `out/host/linux-x86/testcases/ravenwood-runtime` */
    /**
    private static final String RAVENWOOD_RUNTIME_DIR_NAME = "ravenwood-runtime";
     * Env var name for the runtime dir. When running a test locally, it'll contain
     * `/...(path).../out/host/linux-x86/testcases/ravenwood-runtime`.
     */
    private static final String RAVENWOOD_RUNTIME_DIR_ENV = "RAVENWOOD_RUNTIME_DIR";


    private static boolean sEnableExtraRuntimeCheck =
    private static boolean sEnableExtraRuntimeCheck =
            "1".equals(System.getenv("RAVENWOOD_ENABLE_EXTRA_RUNTIME_CHECK"));
            "1".equals(System.getenv("RAVENWOOD_ENABLE_EXTRA_RUNTIME_CHECK"));
@@ -208,36 +211,15 @@ public class RavenwoodCommonUtils {
        if (!isOnRavenwood()) {
        if (!isOnRavenwood()) {
            return null;
            return null;
        }
        }
        var path = System.getProperty("java.library.path");
        var dir = System.getenv(RAVENWOOD_RUNTIME_DIR_ENV);

        if (dir == null || dir.isEmpty()) {
        System.out.println("Looking for " + RAVENWOOD_RUNTIME_DIR_NAME + " directory"
            throw new IllegalStateException("$" + RAVENWOOD_RUNTIME_DIR_ENV + " not set");
                + " in java.library.path:" + path);

        try {
            if (path == null) {
                throw new IllegalStateException("java.library.path shouldn't be null");
            }
            for (var dir : path.split(":")) {

                // For each path, see if the path contains RAVENWOOD_RUNTIME_DIR_NAME.
                var d = new File(dir);
                for (;;) {
                    if (d.getParent() == null) {
                        break; // Root dir, stop.
                    }
                    if (RAVENWOOD_RUNTIME_DIR_NAME.equals(d.getName())) {
                        var ret = d.getAbsolutePath() + "/";
                        System.out.println("Found: " + ret);
                        return ret;
                    }
                    d = d.getParentFile();
        }
        }
        if (!(new File(dir).isDirectory())) {
            throw new IllegalStateException("$" + RAVENWOOD_RUNTIME_DIR_ENV + " contains "
                    + dir + ", but it's not a directory");
        }
        }
            throw new IllegalStateException(RAVENWOOD_RUNTIME_DIR_NAME + " not found");
        return dir;
        } catch (Throwable e) {
            dumpFiles(System.out);
            throw e;
        }
    }
    }


    /** Close an {@link AutoCloseable}. */
    /** Close an {@link AutoCloseable}. */