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

Commit e23eecec authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Improve run-ravenwood-tess.sh -s" into main

parents 5251999f 1de2b182
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static org.junit.Assert.fail;
import android.os.SystemClock;
import android.platform.test.annotations.Presubmit;

import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;

import java.util.ArrayList;
@@ -232,6 +233,7 @@ public class RateLimitingCacheTest {
     * of order.
     */
    @Test
    @LargeTest
    public void testMultipleThreads_cachedValueNeverGoesBackInTime() throws InterruptedException {
        final long periodMillis = 10;
        final int maxCountPerPeriod = 3;
+20 −7
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase

        mTestClass = new TestClass(testClass);

        Log.v(TAG, "RavenwoodAwareTestRunner initializing for " + testClass.getCanonicalName());
        Log.i(TAG, "RavenwoodAwareTestRunner initializing for " + testClass.getCanonicalName());

        // Hook point to allow more customization.
        runAnnotatedMethodsOnRavenwood(RavenwoodTestRunnerInitializing.class, null);
@@ -168,7 +168,9 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase
        RavenwoodTestStats.getInstance().attachToRunNotifier(notifier);

        if (mRealRunner instanceof ClassSkippingTestRunner) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.v(TAG, "onClassSkipped: description=" + description);
            }
            mRealRunner.run(notifier);
            return;
        }
@@ -280,7 +282,9 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase
     * Return false if it should be skipped.
     */
    private boolean onBefore(Description description, Scope scope, Order order) {
        if (RAVENWOOD_VERBOSE_LOGGING) {
            Log.v(TAG, "onBefore: description=" + description + ", " + scope + ", " + order);
        }

        final var classDescription = getDescription();

@@ -306,7 +310,10 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase
     * Return false if the exception should be ignored.
     */
    private boolean onAfter(Description description, Scope scope, Order order, Throwable th) {
        Log.v(TAG, "onAfter: description=" + description + ", " + scope + ", " + order + ", " + th);
        if (RAVENWOOD_VERBOSE_LOGGING) {
            Log.v(TAG, "onAfter: description=" + description + ", " + scope + ", " + order + ", "
                    + th);
        }

        final var classDescription = getDescription();

@@ -350,7 +357,9 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase
     * Called by RavenwoodRule.
     */
    static void onRavenwoodRuleEnter(Description description, RavenwoodRule rule) {
        if (RAVENWOOD_VERBOSE_LOGGING) {
            Log.v(TAG, "onRavenwoodRuleEnter: description=" + description);
        }
        getCurrentRunner().mState.enterRavenwoodRule(rule);
    }

@@ -358,7 +367,9 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase
     * Called by RavenwoodRule.
     */
    static void onRavenwoodRuleExit(Description description, RavenwoodRule rule) {
        if (RAVENWOOD_VERBOSE_LOGGING) {
            Log.v(TAG, "onRavenwoodRuleExit: description=" + description);
        }
        getCurrentRunner().mState.exitRavenwoodRule(rule);
    }

@@ -367,7 +378,9 @@ public final class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase
    }

    private void dumpDescription(Description desc, String header, String indent) {
        if (RAVENWOOD_VERBOSE_LOGGING) {
            Log.v(TAG, indent + header + desc);
        }

        var children = desc.getChildren();
        var childrenIndent = "  " + indent;
+10 −10
Original line number Diff line number Diff line
@@ -732,7 +732,7 @@ public class RavenwoodRuntimeEnvironmentController {
    }

    private static void dumpCommandLineArgs() {
        Log.v(TAG, "JVM arguments:");
        Log.i(TAG, "JVM arguments:");

        // Note, we use the wrapper in JUnit4, not the actual class (
        // java.lang.management.ManagementFactory), because we can't see the later at the build
@@ -741,7 +741,7 @@ public class RavenwoodRuntimeEnvironmentController {
        var args = ManagementFactory.getRuntimeMXBean().getInputArguments();

        for (var arg : args) {
            Log.v(TAG, "  " + arg);
            Log.i(TAG, "  " + arg);
        }
    }

@@ -776,31 +776,31 @@ public class RavenwoodRuntimeEnvironmentController {
    }

    private static void dumpJavaProperties() {
        Log.v(TAG, "JVM properties:");
        Log.i(TAG, "JVM properties:");
        dumpMap(System.getProperties());
    }

    private static void dumpEnvironment() {
        Log.v(TAG, "Environment:");
        Log.i(TAG, "Environment:");
        dumpMap(System.getenv());
    }

    private static void dumpMap(Map<?, ?> map) {
        for (var key : map.keySet().stream().sorted().toList()) {
            Log.v(TAG, "  " + key + "=" + map.get(key));
            Log.i(TAG, "  " + key + "=" + map.get(key));
        }
    }
    private static void dumpOtherInfo() {
        Log.v(TAG, "Other key information:");
        Log.i(TAG, "Other key information:");
        var jloc = Locale.getDefault();
        Log.v(TAG, "  java.util.Locale=" + jloc + " / " + jloc.toLanguageTag());
        Log.i(TAG, "  java.util.Locale=" + jloc + " / " + jloc.toLanguageTag());
        var uloc = ULocale.getDefault();
        Log.v(TAG, "  android.icu.util.ULocale=" + uloc + " / " + uloc.toLanguageTag());
        Log.i(TAG, "  android.icu.util.ULocale=" + uloc + " / " + uloc.toLanguageTag());

        var jtz = java.util.TimeZone.getDefault();
        Log.v(TAG, "  java.util.TimeZone=" + jtz.getDisplayName() + " / " + jtz);
        Log.i(TAG, "  java.util.TimeZone=" + jtz.getDisplayName() + " / " + jtz);

        var itz = android.icu.util.TimeZone.getDefault();
        Log.v(TAG, "  android.icu.util.TimeZone="  + itz.getDisplayName() + " / " + itz);
        Log.i(TAG, "  android.icu.util.TimeZone="  + itz.getDisplayName() + " / " + itz);
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public class RavenwoodSystemProperties {
        var ravenwoodProps = readProperties(path + RAVENWOOD_BUILD_PROP);
        var deviceProps = readProperties(path + DEVICE_BUILD_PROP);

        Log.v(TAG, "Default system properties:");
        Log.i(TAG, "Default system properties:");
        ravenwoodProps.forEach((key, origValue) -> {
            final String value;

@@ -102,11 +102,11 @@ public class RavenwoodSystemProperties {
                var deviceKey = origValue.substring(3);
                if ("r".equals(deviceKey)) {
                    sReadableKeys.add(key);
                    Log.v(TAG, key + " (readable)");
                    Log.i(TAG, key + " (readable)");
                    return;
                } else if ("w".equals(deviceKey)) {
                    sWritableKeys.add(key);
                    Log.v(TAG, key + " (writable)");
                    Log.i(TAG, key + " (writable)");
                    return;
                }

@@ -119,7 +119,7 @@ public class RavenwoodSystemProperties {
            } else {
                value = origValue;
            }
            Log.v(TAG, key + "=" + value);
            Log.i(TAG, key + "=" + value);
            sDefaultValues.put(key, value);
        });

+29 −9
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package android.platform.test.ravenwood;

import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING;

import android.util.Log;

import org.junit.runner.Description;
@@ -188,34 +190,46 @@ public class RavenwoodTestStats {
    private final RunListener mRunListener = new RunListener() {
        @Override
        public void testSuiteStarted(Description description) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "testSuiteStarted: " + description);
            }
        }

        @Override
        public void testSuiteFinished(Description description) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "testSuiteFinished: " + description);
            }
        }

        @Override
        public void testRunStarted(Description description) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "testRunStarted: " + description);
            }
        }

        @Override
        public void testRunFinished(org.junit.runner.Result result) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "testRunFinished: " + result);
            }

            dumpAllAndClear();
        }

        @Override
        public void testStarted(Description description) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "  testStarted: " + description);
            }
        }

        @Override
        public void testFinished(Description description) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "  testFinished: " + description);
            }

            // Send "Passed", but if there's already another result sent for this, this won't
            // override it.
@@ -224,7 +238,9 @@ public class RavenwoodTestStats {

        @Override
        public void testFailure(Failure failure) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "    testFailure: " + failure);
            }

            var description = failure.getDescription();
            onTestFinished(description.getClassName(), description.getMethodName(), Result.Failed);
@@ -232,14 +248,18 @@ public class RavenwoodTestStats {

        @Override
        public void testAssumptionFailure(Failure failure) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "    testAssumptionFailure: " + failure);
            }
            var description = failure.getDescription();
            onTestFinished(description.getClassName(), description.getMethodName(), Result.Skipped);
        }

        @Override
        public void testIgnored(Description description) {
            if (RAVENWOOD_VERBOSE_LOGGING) {
                Log.d(TAG, "    testIgnored: " + description);
            }
            onTestFinished(description.getClassName(), description.getMethodName(), Result.Skipped);
        }
    };
Loading