Fix metric reporting from AVFHostTestCase

Metrics are not being picked up by the CI from this test. TestMetric
object must be a @Rule.

Test: atest AVFHostTestCases
Change-Id: I02d82160196f01301e46cf4852cc5daef6cbb203
This commit is contained in:
David Brazdil 2022-09-07 13:23:47 +01:00
parent 8487f47d2d
commit 2a3537d175
1 changed files with 3 additions and 2 deletions

View File

@ -34,6 +34,7 @@ import com.android.tradefed.util.CommandResult;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -66,6 +67,7 @@ public final class AVFHostTestCase extends MicrodroidHostTestCaseBase {
private static final String METRIC_PREFIX = "avf_perf/hostside/"; private static final String METRIC_PREFIX = "avf_perf/hostside/";
private final MetricsProcessor mMetricsProcessor = new MetricsProcessor(METRIC_PREFIX); private final MetricsProcessor mMetricsProcessor = new MetricsProcessor(METRIC_PREFIX);
@Rule public TestMetrics mMetrics = new TestMetrics();
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
@ -166,9 +168,8 @@ public final class AVFHostTestCase extends MicrodroidHostTestCaseBase {
private void reportMetric(List<Double> data, String name, String unit) { private void reportMetric(List<Double> data, String name, String unit) {
Map<String, Double> stats = mMetricsProcessor.computeStats(data, name, unit); Map<String, Double> stats = mMetricsProcessor.computeStats(data, name, unit);
TestMetrics metrics = new TestMetrics();
for (Map.Entry<String, Double> entry : stats.entrySet()) { for (Map.Entry<String, Double> entry : stats.entrySet()) {
metrics.addTestMetric(entry.getKey(), Double.toString(entry.getValue())); mMetrics.addTestMetric(entry.getKey(), entry.getValue().toString());
} }
} }