add --modulo A B option to gm, so we can only execute 1/B of the tests in a
given instance.
Review URL: https://codereview.appspot.com/6739044
git-svn-id: http://skia.googlecode.com/svn/trunk@6007 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 3cac1e4..9a9ccb1 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -893,6 +893,9 @@
SkTDArray<size_t> configs;
bool userConfig = false;
+ int moduloIndex = -1;
+ int moduloCount = -1;
+
gNotifyMissingReadReference = true;
const char* const commandName = argv[0];
@@ -935,6 +938,18 @@
doPDF = false;
} else if (strcmp(*argv, "--nodeferred") == 0) {
doDeferred = false;
+ } else if (strcmp(*argv, "--modulo") == 0) {
+ ++argv;
+ if (argv >= stop) {
+ continue;
+ }
+ moduloIndex = atoi(*argv);
+
+ ++argv;
+ if (argv >= stop) {
+ continue;
+ }
+ moduloCount = atoi(*argv);
} else if (strcmp(*argv, "--disable-missing-warning") == 0) {
gNotifyMissingReadReference = false;
} else if (strcmp(*argv, "--enable-missing-warning") == 0) {
@@ -1007,6 +1022,13 @@
fprintf(stderr, "reading resources from %s\n", resourcePath);
}
+ if (moduloCount <= 0) {
+ moduloIndex = -1;
+ }
+ if (moduloIndex < 0 || moduloIndex >= moduloCount) {
+ moduloIndex = -1;
+ }
+
// Accumulate success of all tests.
int testsRun = 0;
int testsPassed = 0;
@@ -1022,9 +1044,21 @@
SkTArray<SkString> failedTests;
+ int gmIndex = -1;
+ SkString moduloStr;
+
Iter iter;
GM* gm;
while ((gm = iter.next()) != NULL) {
+
+ ++gmIndex;
+ if (moduloIndex >= 0) {
+ if ((gmIndex % moduloCount) != moduloIndex) {
+ continue;
+ }
+ moduloStr.printf("[%d % %d] ", gmIndex, moduloCount);
+ }
+
const char* shortName = gm->shortName();
if (skip_name(fMatches, shortName)) {
SkDELETE(gm);
@@ -1032,7 +1066,7 @@
}
SkISize size = gm->getISize();
- SkDebugf("drawing... %s [%d %d]\n", shortName,
+ SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName,
size.width(), size.height());
SkBitmap forwardRenderedBitmap;