Don't allow DeviceTypeRule unless it will work correctly.
Handled similar to how this is handled in functional
reference gerrit - ag/25841150
This change allows Microbenchmark to include DeviceTypeRule
Bug: 321787119
Test: ABTD Runs
ABTD Run - https://android-build.corp.google.com/builds/abtd/run/L83000030002287521
Change-Id: I0be7d36c51f43911bea511c8a138d3294a041b0a
diff --git a/libraries/health/runners/microbenchmark/src/android/platform/test/microbenchmark/Microbenchmark.java b/libraries/health/runners/microbenchmark/src/android/platform/test/microbenchmark/Microbenchmark.java
index 7c46a12..2f4260c 100644
--- a/libraries/health/runners/microbenchmark/src/android/platform/test/microbenchmark/Microbenchmark.java
+++ b/libraries/health/runners/microbenchmark/src/android/platform/test/microbenchmark/Microbenchmark.java
@@ -24,11 +24,26 @@
import android.os.SystemClock;
import android.platform.test.composer.Iterate;
import android.platform.test.rule.DynamicRuleChain;
+import android.platform.test.rule.HandlesClassLevelExceptions;
import android.platform.test.rule.TracePointRule;
import android.util.Log;
+
import androidx.annotation.VisibleForTesting;
import androidx.test.InstrumentationRegistry;
+import org.junit.internal.AssumptionViolatedException;
+import org.junit.internal.runners.model.EachTestNotifier;
+import org.junit.internal.runners.model.ReflectiveCallable;
+import org.junit.internal.runners.statements.RunAfters;
+import org.junit.rules.RunRules;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -39,19 +54,6 @@
import java.util.List;
import java.util.Map;
-import org.junit.internal.AssumptionViolatedException;
-import org.junit.internal.runners.model.EachTestNotifier;
-import org.junit.internal.runners.model.ReflectiveCallable;
-import org.junit.internal.runners.statements.RunAfters;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runner.notification.RunNotifier;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.InitializationError;
-import org.junit.runners.model.Statement;
-import org.junit.rules.RunRules;
-
/**
* The {@code Microbenchmark} runner allows you to run individual JUnit {@code @Test} methods
* repeatedly like a benchmark test in order to get more repeatable, reliable measurements, or to
@@ -69,6 +71,7 @@
* documented below), and can be configured to terminate early if the battery drops too low or if
* any test fails.
*/
+@HandlesClassLevelExceptions
public class Microbenchmark extends BlockJUnit4ClassRunner {
private static final String LOG_TAG = Microbenchmark.class.getSimpleName();