SkQP: run a single test
PLEASE NOTE: Instructions on running `am instrument` for the SkQP APK have changed. To run a single test, see the section "Running a single test" in `tools/skqp/README.md`. No-Try: true Change-Id: I0a2cbc47755929d6c6a927a3591ff98046779c77 Reviewed-on: https://skia-review.googlesource.com/108780 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
cdcadf7a29
commit
f637cc01f8
@ -29,6 +29,6 @@
|
||||
</activity>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
|
||||
<instrumentation android:name="org.skia.skqp.SkQPAndroidRunner"
|
||||
android:targetPackage="org.skia.skqp"></instrumentation>
|
||||
</manifest>
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package org.skia.skqp;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.test.runner.AndroidJUnitRunner;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class SkQPAndroidRunner extends AndroidJUnitRunner {
|
||||
@Override
|
||||
public void onCreate(Bundle args) {
|
||||
String filter = args.getString("skqp_filter");
|
||||
if (filter != null) {
|
||||
gFilters = new HashSet<String>();
|
||||
for (String f : filter.split(",")) {
|
||||
gFilters.add(f);
|
||||
}
|
||||
}
|
||||
super.onCreate(args);
|
||||
}
|
||||
public static boolean filter(String s) { return gFilters == null || gFilters.contains(s); }
|
||||
private static HashSet<String> gFilters;
|
||||
}
|
@ -14,7 +14,6 @@ import android.support.test.InstrumentationRegistry;
|
||||
import android.util.Log;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runner.Runner;
|
||||
@ -37,6 +36,15 @@ public class SkQPRunner extends Runner {
|
||||
File f = c.getExternalFilesDir(null);
|
||||
return new File(f, "output");
|
||||
}
|
||||
|
||||
private Description gmDesc(int backend, int gm) {
|
||||
return Description.createTestDescription(
|
||||
SkQP.kSkiaGM + impl.mBackends[backend], impl.mGMs[gm]);
|
||||
}
|
||||
private Description unitDesc(int test) {
|
||||
return Description.createTestDescription(SkQP.kSkiaUnitTests, impl.mUnitTests[test]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public SkQPRunner(Class testClass) {
|
||||
@ -54,17 +62,13 @@ public class SkQPRunner extends Runner {
|
||||
impl.nInit(mAssetManager, filesDir.getAbsolutePath(), false);
|
||||
|
||||
mDescription = Description.createSuiteDescription(testClass);
|
||||
Annotation annots[] = new Annotation[0];
|
||||
for (int backend = 0; backend < impl.mBackends.length; backend++) {
|
||||
String classname = SkQP.kSkiaGM + impl.mBackends[backend];
|
||||
for (int gm = 0; gm < impl.mGMs.length; gm++) {
|
||||
mDescription.addChild(
|
||||
Description.createTestDescription(classname, impl.mGMs[gm], annots));
|
||||
mDescription.addChild(this.gmDesc(backend, gm));
|
||||
}
|
||||
}
|
||||
for (int unitTest = 0; unitTest < impl.mUnitTests.length; unitTest++) {
|
||||
mDescription.addChild(Description.createTestDescription(SkQP.kSkiaUnitTests,
|
||||
impl.mUnitTests[unitTest], annots));
|
||||
mDescription.addChild(this.unitDesc(unitTest));
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,16 +84,17 @@ public class SkQPRunner extends Runner {
|
||||
public void run(RunNotifier notifier) {
|
||||
int numberOfTests = this.testCount();
|
||||
int testNumber = 1;
|
||||
Annotation annots[] = new Annotation[0];
|
||||
for (int backend = 0; backend < impl.mBackends.length; backend++) {
|
||||
String classname = SkQP.kSkiaGM + impl.mBackends[backend];
|
||||
for (int gm = 0; gm < impl.mGMs.length; gm++) {
|
||||
String gmName = String.format("%s/%s", impl.mBackends[backend], impl.mGMs[gm]);
|
||||
if (!SkQPAndroidRunner.filter(gmName)) {
|
||||
continue;
|
||||
}
|
||||
Log.v(TAG, String.format("Rendering Test %s started (%d/%d).",
|
||||
gmName, testNumber, numberOfTests));
|
||||
testNumber++;
|
||||
Description desc =
|
||||
Description.createTestDescription(classname, impl.mGMs[gm], annots);
|
||||
Description desc = this.gmDesc(backend, gm);
|
||||
notifier.fireTestStarted(desc);
|
||||
float value = java.lang.Float.MAX_VALUE;
|
||||
String error = null;
|
||||
@ -113,11 +118,13 @@ public class SkQPRunner extends Runner {
|
||||
}
|
||||
for (int unitTest = 0; unitTest < impl.mUnitTests.length; unitTest++) {
|
||||
String utName = impl.mUnitTests[unitTest];
|
||||
if (!SkQPAndroidRunner.filter(String.format("unitTest/%s", utName))) {
|
||||
continue;
|
||||
}
|
||||
Log.v(TAG, String.format("Test %s started (%d/%d).",
|
||||
utName, testNumber, numberOfTests));
|
||||
testNumber++;
|
||||
Description desc = Description.createTestDescription(
|
||||
SkQP.kSkiaUnitTests, utName, annots);
|
||||
Description desc = this.unitDesc(unitTest);
|
||||
notifier.fireTestStarted(desc);
|
||||
String[] errors = impl.nExecuteUnitTest(unitTest);
|
||||
if (errors != null && errors.length > 0) {
|
||||
|
@ -23,7 +23,7 @@ To run tests:
|
||||
|
||||
adb install -r skqp-universal-{APK_SHA_HERE}.apk
|
||||
adb logcat -c
|
||||
adb shell am instrument -w org.skia.skqp/android.support.test.runner.AndroidJUnitRunner
|
||||
adb shell am instrument -w org.skia.skqp
|
||||
|
||||
Monitor the output with:
|
||||
|
||||
|
@ -64,7 +64,7 @@ How to build and run the SkQP tests
|
||||
platform_tools/android/bin/android_build_app -C out/skqp-arm skqp
|
||||
adb install -r out/skqp-arm/skqp.apk
|
||||
adb logcat -c
|
||||
adb shell am instrument -w org.skia.skqp/android.support.test.runner.AndroidJUnitRunner
|
||||
adb shell am instrument -w org.skia.skqp
|
||||
|
||||
6. Monitor the output with:
|
||||
|
||||
@ -81,6 +81,21 @@ How to build and run the SkQP tests
|
||||
adb pull $OUTPUT_LOCATION /tmp/
|
||||
tools/skqp/sysopen.py /tmp/output/skqp_report/report.html
|
||||
|
||||
Running a single test
|
||||
---------------------
|
||||
|
||||
To run a single test, for example `gles/aarectmodes`:
|
||||
|
||||
adb shell am instrument -e skqp_filter gles/aarectmodes -w org.skia.skqp
|
||||
|
||||
Two run multiple tests, simply separate them with commas:
|
||||
|
||||
adb shell am instrument -e skqp_filter gles/aarectmodes,vk/aarectmodes -w org.skia.skqp
|
||||
|
||||
Unit tests can be run with the `unitTest/` prefix:
|
||||
|
||||
adb shell am instrument -e skqp_filter unitTest/GrSurface -w org.skia.skqp
|
||||
|
||||
Run as a non-APK executable
|
||||
---------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user