Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: dm/DM.cpp

Issue 2243143002: Add --serial mode to dm, runs unit tests serially (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Run test serially Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | infra/bots/recipes/swarm_test.py » ('j') | infra/bots/recipes/swarm_test.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "DMJsonWriter.h" 8 #include "DMJsonWriter.h"
9 #include "DMSrcSink.h" 9 #include "DMSrcSink.h"
10 #include "DMSrcSinkAndroid.h" 10 #include "DMSrcSinkAndroid.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 DEFINE_string2(readPath, r, "", "If set check for equality with golden results i n this directory."); 65 DEFINE_string2(readPath, r, "", "If set check for equality with golden results i n this directory.");
66 66
67 DEFINE_string(uninterestingHashesFile, "", 67 DEFINE_string(uninterestingHashesFile, "",
68 "File containing a list of uninteresting hashes. If a result hashes to s omething in " 68 "File containing a list of uninteresting hashes. If a result hashes to s omething in "
69 "this list, no image is written for that result."); 69 "this list, no image is written for that result.");
70 70
71 DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); 71 DEFINE_int32(shards, 1, "We're splitting source data into this many shards.");
72 DEFINE_int32(shard, 0, "Which shard do I run?"); 72 DEFINE_int32(shard, 0, "Which shard do I run?");
73 73
74 DEFINE_string2(serial, s, nullptr,
mtklein 2016/08/16 23:54:06 Why don't we call this flag and the array and so o
msarett 2016/08/17 12:40:45 sgtm was struggling for a name.
75 "Run the specified tests in serial, before creating multiple thre ads.\n"
76 "Test names must match exactly. Multiple tests may be separated by spaces.");
77
74 DEFINE_string(mskps, "", "Directory to read mskps from, or a single mskp file.") ; 78 DEFINE_string(mskps, "", "Directory to read mskps from, or a single mskp file.") ;
75 79
76 DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file."); 80 DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
77 81
78 using namespace DM; 82 using namespace DM;
79 using sk_gpu_test::GrContextFactory; 83 using sk_gpu_test::GrContextFactory;
80 using sk_gpu_test::GLTestContext; 84 using sk_gpu_test::GLTestContext;
81 using sk_gpu_test::ContextInfo; 85 using sk_gpu_test::ContextInfo;
82 86
83 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 87 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 return; 1203 return;
1200 } 1204 }
1201 } 1205 }
1202 } 1206 }
1203 }; 1207 };
1204 1208
1205 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1209 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1206 1210
1207 // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment. 1211 // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
1208 1212
1209 static SkTDArray<skiatest::Test> gParallelTests, gSerialTests; 1213 static SkTDArray<skiatest::Test> gParallelTests, gSerialTests, gSerialRunAloneTe sts;
1214
1215 static bool name_in_string_array(const SkCommandLineFlags::StringArray& strings, const char* name) {
1216 for (int i = 0; i < strings.count(); i++) {
1217 const char* string = strings[i];
1218 if (0 == strcmp(string, name)) {
1219 return true;
1220 }
1221 }
1222 return false;
1223 }
1210 1224
1211 static void gather_tests() { 1225 static void gather_tests() {
1212 if (!FLAGS_src.contains("tests")) { 1226 if (!FLAGS_src.contains("tests")) {
1213 return; 1227 return;
1214 } 1228 }
1215 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) { 1229 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) {
1216 if (!in_shard()) { 1230 if (!in_shard()) {
1217 continue; 1231 continue;
1218 } 1232 }
1219 // Despite its name, factory() is returning a reference to 1233 // Despite its name, factory() is returning a reference to
1220 // link-time static const POD data. 1234 // link-time static const POD data.
1221 const skiatest::Test& test = r->factory(); 1235 const skiatest::Test& test = r->factory();
1222 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) { 1236 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) {
1223 continue; 1237 continue;
1224 } 1238 }
1239 if (name_in_string_array(FLAGS_serial, test.name)) {
mtklein 2016/08/16 23:54:06 Probably better as if (FLAGS_serial.contains(test
msarett 2016/08/17 12:40:45 Ahh yes, done.
1240 gSerialRunAloneTests.push(test);
1241 continue;
1242 }
1225 if (test.needsGpu && gpu_supported()) { 1243 if (test.needsGpu && gpu_supported()) {
1226 (FLAGS_gpu_threading ? gParallelTests : gSerialTests).push(test); 1244 (FLAGS_gpu_threading ? gParallelTests : gSerialTests).push(test);
1227 } else if (!test.needsGpu && FLAGS_cpu) { 1245 } else if (!test.needsGpu && FLAGS_cpu) {
1228 gParallelTests.push(test); 1246 gParallelTests.push(test);
1229 } 1247 }
1230 } 1248 }
1231 } 1249 }
1232 1250
1233 static void run_test(skiatest::Test test) { 1251 static void run_test(skiatest::Test test) {
1234 struct : public skiatest::Reporter { 1252 struct : public skiatest::Reporter {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 gather_gold(); 1328 gather_gold();
1311 gather_uninteresting_hashes(); 1329 gather_uninteresting_hashes();
1312 1330
1313 if (!gather_srcs()) { 1331 if (!gather_srcs()) {
1314 return 1; 1332 return 1;
1315 } 1333 }
1316 if (!gather_sinks()) { 1334 if (!gather_sinks()) {
1317 return 1; 1335 return 1;
1318 } 1336 }
1319 gather_tests(); 1337 gather_tests();
1338
1339 // First, run memory intensive tests serially.
1340 if (gSerialRunAloneTests.count() > 0) {
1341 info("Running %d tests serially...\n", gSerialRunAloneTests.count());
1342 for (auto test : gSerialRunAloneTests) { run_test(test); }
1343 }
1344
1320 gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerial Tests.count(); 1345 gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerial Tests.count();
1321 info("%d srcs * %d sinks + %d tests == %d tasks", 1346 info("%d srcs * %d sinks + %d tests == %d tasks",
1322 gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.co unt(), gPending); 1347 gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.co unt(), gPending);
1323 SkAutoTDelete<SkThread> statusThread(start_status_thread()); 1348 SkAutoTDelete<SkThread> statusThread(start_status_thread());
1324 1349
1325 // Kick off as much parallel work as we can, making note of any serial work we'll need to do. 1350 // Kick off as much parallel work as we can, making note of any serial work we'll need to do.
1326 SkTaskGroup parallel; 1351 SkTaskGroup parallel;
1327 SkTArray<Task> serial; 1352 SkTArray<Task> serial;
1328 1353
1329 for (auto& sink : gSinks) 1354 for (auto& sink : gSinks)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 #endif 1460 #endif
1436 } 1461 }
1437 } // namespace skiatest 1462 } // namespace skiatest
1438 1463
1439 #if !defined(SK_BUILD_FOR_IOS) 1464 #if !defined(SK_BUILD_FOR_IOS)
1440 int main(int argc, char** argv) { 1465 int main(int argc, char** argv) {
1441 SkCommandLineFlags::Parse(argc, argv); 1466 SkCommandLineFlags::Parse(argc, argv);
1442 return dm_main(); 1467 return dm_main();
1443 } 1468 }
1444 #endif 1469 #endif
OLDNEW
« no previous file with comments | « no previous file | infra/bots/recipes/swarm_test.py » ('j') | infra/bots/recipes/swarm_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698