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

Commit 24b00ea7 authored by John Wu's avatar John Wu
Browse files

[Ravenizer] Use HostStubGen to process test and target code

Bug: 397498134
Flag: EXEMPT host side change only
Test: f/b/r/scripts/run-ravenwood-tests.sh
Change-Id: Ib298d31adccb1e5ba2b65f4329971adad69926d9
parent 9e244748
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ filegroup {
    srcs: [
        "texts/ravenwood-common-policies.txt",
    ],
    visibility: ["//visibility:private"],
    visibility: [":__subpackages__"],
}

filegroup {
@@ -43,6 +43,22 @@ filegroup {
    visibility: ["//visibility:private"],
}

filegroup {
    name: "ravenwood-standard-annotations",
    srcs: [
        "texts/ravenwood-standard-annotations.txt",
    ],
    visibility: [":__subpackages__"],
}

filegroup {
    name: "ravenizer-standard-options",
    srcs: [
        "texts/ravenizer-standard-options.txt",
    ],
    visibility: [":__subpackages__"],
}

filegroup {
    name: "ravenwood-annotation-allowed-classes",
    srcs: [
+12 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ genrule_defaults {
        ":ravenwood-common-policies",
        ":ravenwood-framework-policies",
        ":ravenwood-standard-options",
        ":ravenwood-standard-annotations",
        ":ravenwood-annotation-allowed-classes",
    ],
    out: [
@@ -44,6 +45,7 @@ genrule_defaults {

framework_minus_apex_cmd = "$(location hoststubgen) " +
    "@$(location :ravenwood-standard-options) " +
    "@$(location :ravenwood-standard-annotations) " +
    "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
    "--out-jar $(location ravenwood.jar) " +
    "--in-jar $(location :framework-minus-apex-for-host) " +
@@ -178,6 +180,7 @@ java_genrule {
    tools: ["hoststubgen"],
    cmd: "$(location hoststubgen) " +
        "@$(location :ravenwood-standard-options) " +
        "@$(location :ravenwood-standard-annotations) " +

        "--debug-log $(location hoststubgen_services.core.log) " +
        "--stats-file $(location hoststubgen_services.core_stats.csv) " +
@@ -196,6 +199,7 @@ java_genrule {
        ":ravenwood-common-policies",
        ":ravenwood-services-policies",
        ":ravenwood-standard-options",
        ":ravenwood-standard-annotations",
        ":ravenwood-annotation-allowed-classes",
    ],
    out: [
@@ -247,6 +251,7 @@ java_genrule {
    tools: ["hoststubgen"],
    cmd: "$(location hoststubgen) " +
        "@$(location :ravenwood-standard-options) " +
        "@$(location :ravenwood-standard-annotations) " +

        "--debug-log $(location hoststubgen_core-icu4j-for-host.log) " +
        "--stats-file $(location hoststubgen_core-icu4j-for-host_stats.csv) " +
@@ -265,6 +270,7 @@ java_genrule {
        ":ravenwood-common-policies",
        ":icu-ravenwood-policies",
        ":ravenwood-standard-options",
        ":ravenwood-standard-annotations",
    ],
    out: [
        "ravenwood.jar",
@@ -301,6 +307,7 @@ java_genrule {
    tools: ["hoststubgen"],
    cmd: "$(location hoststubgen) " +
        "@$(location :ravenwood-standard-options) " +
        "@$(location :ravenwood-standard-annotations) " +

        "--debug-log $(location framework-configinfrastructure.log) " +
        "--stats-file $(location framework-configinfrastructure_stats.csv) " +
@@ -319,6 +326,7 @@ java_genrule {
        ":ravenwood-common-policies",
        ":framework-configinfrastructure-ravenwood-policies",
        ":ravenwood-standard-options",
        ":ravenwood-standard-annotations",
    ],
    out: [
        "ravenwood.jar",
@@ -355,6 +363,7 @@ java_genrule {
    tools: ["hoststubgen"],
    cmd: "$(location hoststubgen) " +
        "@$(location :ravenwood-standard-options) " +
        "@$(location :ravenwood-standard-annotations) " +

        "--debug-log $(location framework-statsd.log) " +
        "--stats-file $(location framework-statsd_stats.csv) " +
@@ -373,6 +382,7 @@ java_genrule {
        ":ravenwood-common-policies",
        ":framework-statsd-ravenwood-policies",
        ":ravenwood-standard-options",
        ":ravenwood-standard-annotations",
    ],
    out: [
        "ravenwood.jar",
@@ -409,6 +419,7 @@ java_genrule {
    tools: ["hoststubgen"],
    cmd: "$(location hoststubgen) " +
        "@$(location :ravenwood-standard-options) " +
        "@$(location :ravenwood-standard-annotations) " +

        "--debug-log $(location framework-graphics.log) " +
        "--stats-file $(location framework-graphics_stats.csv) " +
@@ -427,6 +438,7 @@ java_genrule {
        ":ravenwood-common-policies",
        ":framework-graphics-ravenwood-policies",
        ":ravenwood-standard-options",
        ":ravenwood-standard-annotations",
    ],
    out: [
        "ravenwood.jar",
+63 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.ravenwoodtest.bivalenttest.ravenizer;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;

import org.junit.Test;

import java.io.FileDescriptor;
import java.util.LinkedHashMap;
import java.util.regex.Pattern;

public class RavenwoodJdkPatchTest {

    @Test
    public void testUnicodeRegex() {
        var pattern = Pattern.compile("\\w+");
        assertTrue(pattern.matcher("über").matches());
    }

    @Test
    public void testLinkedHashMapEldest() {
        var map = new LinkedHashMap<String, String>();
        map.put("a", "b");
        map.put("x", "y");
        assertEquals(map.entrySet().iterator().next(), map.eldest());
    }

    @Test
    public void testFileDescriptorGetSetInt() throws ErrnoException {
        FileDescriptor fd = Os.open("/dev/zero", OsConstants.O_RDONLY, 0);
        try {
            int fdRaw = fd.getInt$();
            assertNotEquals(-1, fdRaw);
            fd.setInt$(-1);
            assertEquals(-1, fd.getInt$());
            fd.setInt$(fdRaw);
            Os.close(fd);
            assertEquals(-1, fd.getInt$());
        } finally {
            Os.close(fd);
        }
    }
}
+13 −0
Original line number Diff line number Diff line
# File containing standard options to Ravenizer for Ravenwood

# Keep all classes / methods / fields in tests and its target
--default-keep

--delete-finals

# Include standard annotations
@jar:texts/ravenwood-standard-annotations.txt

# Apply common policies
--policy-override-file
    jar:texts/ravenwood-common-policies.txt
+37 −0
Original line number Diff line number Diff line
# Standard annotations.
# Note, each line is a single argument, so we need newlines after each `--xxx-annotation`.
--keep-annotation
    android.ravenwood.annotation.RavenwoodKeep

--keep-annotation
    android.ravenwood.annotation.RavenwoodKeepPartialClass

--keep-class-annotation
    android.ravenwood.annotation.RavenwoodKeepWholeClass

--throw-annotation
    android.ravenwood.annotation.RavenwoodThrow

--remove-annotation
    android.ravenwood.annotation.RavenwoodRemove

--ignore-annotation
    android.ravenwood.annotation.RavenwoodIgnore

--partially-allowed-annotation
    android.ravenwood.annotation.RavenwoodPartiallyAllowlisted

--substitute-annotation
    android.ravenwood.annotation.RavenwoodReplace

--redirect-annotation
    android.ravenwood.annotation.RavenwoodRedirect

--redirection-class-annotation
    android.ravenwood.annotation.RavenwoodRedirectionClass

--class-load-hook-annotation
    android.ravenwood.annotation.RavenwoodClassLoadHook

--keep-static-initializer-annotation
    android.ravenwood.annotation.RavenwoodKeepStaticInitializer
Loading