blob: bf0690ac5dc2b5b6b0102aabe6163fcf260d759a [file] [log] [blame]
jcgregorio3b27ade2014-11-13 08:06:40 -08001#include "CrashHandler.h"
mtklein748ca3b2015-01-15 10:56:12 -08002#include "DMJsonWriter.h"
3#include "DMSrcSink.h"
4#include "OverwriteLine.h"
5#include "ProcStats.h"
6#include "SkBBHFactory.h"
caryclark17f0b6d2014-07-22 10:15:34 -07007#include "SkCommonFlags.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00008#include "SkForceLinking.h"
9#include "SkGraphics.h"
mtklein748ca3b2015-01-15 10:56:12 -080010#include "SkMD5.h"
mtklein1d0f1642014-09-08 08:05:18 -070011#include "SkOSFile.h"
mtklein406654b2014-09-03 15:34:37 -070012#include "SkTaskGroup.h"
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000013#include "Test.h"
mtklein748ca3b2015-01-15 10:56:12 -080014#include "Timer.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +000015
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000016DEFINE_bool(tests, true, "Run tests?");
mtklein748ca3b2015-01-15 10:56:12 -080017DEFINE_string(images, "resources", "Images to decode.");
mtkleine1315522015-01-15 13:58:56 -080018DEFINE_string(src, "gm skp image subset", "Source types to test.");
mtklein748ca3b2015-01-15 10:56:12 -080019DEFINE_bool(nameByHash, false,
20 "If true, write to FLAGS_writePath[0]/<hash>.png instead of "
21 "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png");
22DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
23DEFINE_string(matrix, "1 0 0 0 1 0 0 0 1",
24 "Matrix to apply when using 'matrix' in config.");
mtklein82d28432015-01-15 12:46:02 -080025DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
mtklein@google.comd36522d2013-10-16 13:02:15 +000026
mtkleina2ef6422015-01-15 13:44:22 -080027DEFINE_string(blacklist, "",
28 "Space-separated config/src/name triples to blacklist. '_' matches anything. E.g. \n"
29 "'--blacklist gpu skp _' will blacklist all SKPs drawn into the gpu config.\n"
30 "'--blacklist gpu skp _ 8888 gm aarects' will also blacklist the aarects GM on 8888.");
31
32
mtklein@google.comd36522d2013-10-16 13:02:15 +000033__SK_FORCE_IMAGE_DECODER_LINKING;
mtklein748ca3b2015-01-15 10:56:12 -080034using namespace DM;
mtklein@google.comd36522d2013-10-16 13:02:15 +000035
mtklein748ca3b2015-01-15 10:56:12 -080036/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
37
38SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
39static SkTArray<SkString> gFailures;
40
41static void fail(ImplicitString err) {
42 SkAutoMutexAcquire lock(gFailuresMutex);
43 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
44 gFailures.push_back(err);
halcanary9e398f72015-01-10 11:18:04 -080045}
46
mtklein748ca3b2015-01-15 10:56:12 -080047static int32_t gPending = 0; // Atomic.
48
49static void done(double ms, ImplicitString config, ImplicitString src, ImplicitString name) {
50 SkDebugf("%s(%4dMB %5d) %s\t%s %s %s ", FLAGS_verbose ? "\n" : kSkOverwriteLine
51 , sk_tools::getMaxResidentSetSizeMB()
52 , sk_atomic_dec(&gPending)-1
53 , HumanizeMs(ms).c_str()
54 , config.c_str()
55 , src.c_str()
56 , name.c_str());
mtklein@google.comd36522d2013-10-16 13:02:15 +000057}
58
mtklein748ca3b2015-01-15 10:56:12 -080059/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
mtklein114c3cd2015-01-15 10:15:02 -080060
mtklein748ca3b2015-01-15 10:56:12 -080061template <typename T>
62struct Tagged : public SkAutoTDelete<T> { const char* tag; };
63
64static const bool kMemcpyOK = true;
65
66static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs;
67static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks;
68
69static void push_src(const char* tag, Src* s) {
70 SkAutoTDelete<Src> src(s);
71 if (FLAGS_src.contains(tag) &&
72 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
73 Tagged<Src>& s = gSrcs.push_back();
74 s.reset(src.detach());
75 s.tag = tag;
mtklein114c3cd2015-01-15 10:15:02 -080076 }
mtklein748ca3b2015-01-15 10:56:12 -080077}
mtklein114c3cd2015-01-15 10:15:02 -080078
mtklein748ca3b2015-01-15 10:56:12 -080079static void gather_srcs() {
80 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) {
81 push_src("gm", new GMSrc(r->factory()));
82 }
83 if (!FLAGS_skps.isEmpty()) {
84 SkOSFile::Iter it(FLAGS_skps[0], "skp");
85 for (SkString file; it.next(&file); ) {
86 push_src("skp", new SKPSrc(SkOSPath::Join(FLAGS_skps[0], file.c_str())));
mtklein114c3cd2015-01-15 10:15:02 -080087 }
88 }
mtklein748ca3b2015-01-15 10:56:12 -080089 if (!FLAGS_images.isEmpty()) {
90 const char* exts[] = {
91 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
92 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
93 };
94 for (size_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
95 SkOSFile::Iter it(FLAGS_images[0], exts[i]);
96 for (SkString file; it.next(&file); ) {
97 SkString path = SkOSPath::Join(FLAGS_images[0], file.c_str());
98 push_src("image", new ImageSrc(path)); // Decode entire image.
99 push_src("subset", new ImageSrc(path, 5)); // Decode 5 random subsets.
mtklein114c3cd2015-01-15 10:15:02 -0800100 }
mtklein709d2c32015-01-15 08:30:25 -0800101 }
mtklein709d2c32015-01-15 08:30:25 -0800102 }
103}
104
mtklein748ca3b2015-01-15 10:56:12 -0800105static GrGLStandard get_gpu_api() {
106 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; }
107 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; }
108 return kNone_GrGLStandard;
mtklein709d2c32015-01-15 08:30:25 -0800109}
110
mtklein748ca3b2015-01-15 10:56:12 -0800111static void push_sink(const char* tag, Sink* s) {
112 SkAutoTDelete<Sink> sink(s);
113 if (!FLAGS_config.contains(tag)) {
114 return;
mtklein114c3cd2015-01-15 10:15:02 -0800115 }
mtklein748ca3b2015-01-15 10:56:12 -0800116 // Try a noop Src as a canary. If it fails, skip this sink.
117 struct : public Src {
118 Error draw(SkCanvas*) const SK_OVERRIDE { return ""; }
119 SkISize size() const SK_OVERRIDE { return SkISize::Make(16, 16); }
120 Name name() const SK_OVERRIDE { return "noop"; }
121 } noop;
mtklein114c3cd2015-01-15 10:15:02 -0800122
mtklein748ca3b2015-01-15 10:56:12 -0800123 SkBitmap bitmap;
124 SkDynamicMemoryWStream stream;
125 Error err = sink->draw(noop, &bitmap, &stream);
126 if (!err.isEmpty()) {
127 SkDebugf("Skipping %s: %s\n", tag, err.c_str());
mtklein114c3cd2015-01-15 10:15:02 -0800128 return;
129 }
130
mtklein748ca3b2015-01-15 10:56:12 -0800131 Tagged<Sink>& ts = gSinks.push_back();
132 ts.reset(sink.detach());
133 ts.tag = tag;
134}
135
136static bool gpu_supported() {
137#if SK_SUPPORT_GPU
138 return FLAGS_gpu;
139#else
140 return false;
141#endif
142}
143
144static Sink* create_sink(const char* tag) {
145#define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); }
146 if (gpu_supported()) {
mtklein82d28432015-01-15 12:46:02 -0800147 typedef GrContextFactory Gr;
mtklein748ca3b2015-01-15 10:56:12 -0800148 const GrGLStandard api = get_gpu_api();
mtklein82d28432015-01-15 12:46:02 -0800149 SINK("gpunull", GPUSink, Gr::kNull_GLContextType, api, 0, false, FLAGS_gpu_threading);
150 SINK("gpudebug", GPUSink, Gr::kDebug_GLContextType, api, 0, false, FLAGS_gpu_threading);
151 SINK("gpu", GPUSink, Gr::kNative_GLContextType, api, 0, false, FLAGS_gpu_threading);
152 SINK("gpudft", GPUSink, Gr::kNative_GLContextType, api, 0, true, FLAGS_gpu_threading);
153 SINK("msaa4", GPUSink, Gr::kNative_GLContextType, api, 4, false, FLAGS_gpu_threading);
154 SINK("msaa16", GPUSink, Gr::kNative_GLContextType, api, 16, false, FLAGS_gpu_threading);
155 SINK("nvprmsaa4", GPUSink, Gr::kNVPR_GLContextType, api, 4, false, FLAGS_gpu_threading);
156 SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, false, FLAGS_gpu_threading);
mtklein748ca3b2015-01-15 10:56:12 -0800157 #if SK_ANGLE
mtklein82d28432015-01-15 12:46:02 -0800158 SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading);
mtklein748ca3b2015-01-15 10:56:12 -0800159 #endif
160 #if SK_MESA
mtklein82d28432015-01-15 12:46:02 -0800161 SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0, false, FLAGS_gpu_threading);
mtklein748ca3b2015-01-15 10:56:12 -0800162 #endif
mtklein114c3cd2015-01-15 10:15:02 -0800163 }
mtklein748ca3b2015-01-15 10:56:12 -0800164
165 if (FLAGS_cpu) {
166 SINK("565", RasterSink, kRGB_565_SkColorType);
167 SINK("8888", RasterSink, kN32_SkColorType);
168 // TODO(mtklein): reenable once skiagold can handle .pdf uploads.
169 //SINK("pdf", PDFSink);
170 }
171#undef SINK
172 return NULL;
mtklein114c3cd2015-01-15 10:15:02 -0800173}
174
mtklein748ca3b2015-01-15 10:56:12 -0800175static Sink* create_via(const char* tag, Sink* wrapped) {
176#define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__); }
177 VIA("serialize", ViaSerialization, wrapped);
178
179 VIA("tiles", ViaTiles, 256, 256, NULL, wrapped);
180 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
181
182 const int xp = SkGPipeWriter::kCrossProcess_Flag,
183 sa = xp | SkGPipeWriter::kSharedAddressSpace_Flag;
184 VIA("pipe", ViaPipe, 0, wrapped);
185 VIA("pipe_xp", ViaPipe, xp, wrapped);
186 VIA("pipe_sa", ViaPipe, sa, wrapped);
187
188 if (FLAGS_matrix.count() == 9) {
189 SkMatrix m;
190 for (int i = 0; i < 9; i++) {
191 m[i] = (SkScalar)atof(FLAGS_matrix[i]);
192 }
193 VIA("matrix", ViaMatrix, m, wrapped);
194 }
195#undef VIA
196 return NULL;
mtklein114c3cd2015-01-15 10:15:02 -0800197}
198
mtklein748ca3b2015-01-15 10:56:12 -0800199static void gather_sinks() {
200 for (int i = 0; i < FLAGS_config.count(); i++) {
201 const char* config = FLAGS_config[i];
202 SkTArray<SkString> parts;
203 SkStrSplit(config, "-", &parts);
204
205 Sink* sink = NULL;
206 for (int i = parts.count(); i-- > 0;) {
207 const char* part = parts[i].c_str();
208 Sink* next = (sink == NULL) ? create_sink(part) : create_via(part, sink);
209 if (next == NULL) {
210 SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part);
211 delete sink;
212 sink = NULL;
213 break;
214 }
215 sink = next;
216 }
217 if (sink) {
218 push_sink(config, sink);
mtklein114c3cd2015-01-15 10:15:02 -0800219 }
220 }
221}
mtklein709d2c32015-01-15 08:30:25 -0800222
mtkleina2ef6422015-01-15 13:44:22 -0800223static bool match(const char* needle, const char* haystack) {
224 return 0 == strcmp("_", needle) || NULL != strstr(haystack, needle);
225}
226
227static ImplicitString is_blacklisted(const char* sink, const char* src, const char* name) {
228 for (int i = 0; i < FLAGS_blacklist.count() - 2; i += 3) {
229 if (match(FLAGS_blacklist[i+0], sink) &&
230 match(FLAGS_blacklist[i+1], src) &&
231 match(FLAGS_blacklist[i+2], name)) {
232 return SkStringPrintf("%s %s %s",
233 FLAGS_blacklist[i+0], FLAGS_blacklist[i+1], FLAGS_blacklist[i+2]);
234 }
235 }
236 return "";
237}
238
mtklein748ca3b2015-01-15 10:56:12 -0800239// The finest-grained unit of work we can run: draw a single Src into a single Sink,
240// report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream.
241struct Task {
242 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink) {}
243 const Tagged<Src>& src;
244 const Tagged<Sink>& sink;
245
246 static void Run(Task* task) {
mtkleina2ef6422015-01-15 13:44:22 -0800247 SkString name = task->src->name();
248 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag, name.c_str());
mtklein748ca3b2015-01-15 10:56:12 -0800249 WallTimer timer;
250 timer.start();
mtkleina2ef6422015-01-15 13:44:22 -0800251 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) {
mtklein748ca3b2015-01-15 10:56:12 -0800252 SkBitmap bitmap;
253 SkDynamicMemoryWStream stream;
254 Error err = task->sink->draw(*task->src, &bitmap, &stream);
255 if (!err.isEmpty()) {
256 fail(SkStringPrintf("%s %s %s: %s",
257 task->sink.tag,
258 task->src.tag,
mtkleina2ef6422015-01-15 13:44:22 -0800259 name.c_str(),
mtklein748ca3b2015-01-15 10:56:12 -0800260 err.c_str()));
261 }
262 if (!FLAGS_writePath.isEmpty()) {
263 const char* ext = task->sink->fileExtension();
264 if (stream.bytesWritten() == 0) {
265 SkMemoryStream pixels(bitmap.getPixels(), bitmap.getSize());
266 WriteToDisk(*task, &pixels, bitmap.getSize(), &bitmap, ext);
267 } else {
268 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream());
269 WriteToDisk(*task, data, data->getLength(), NULL, ext);
270 }
271 }
272 }
273 timer.end();
mtkleina2ef6422015-01-15 13:44:22 -0800274 if (!whyBlacklisted.isEmpty()) {
275 name.appendf(" (--blacklist, %s)", whyBlacklisted.c_str());
276 }
277 done(timer.fWall, task->sink.tag, task->src.tag, name);
mtklein748ca3b2015-01-15 10:56:12 -0800278 }
279
280 static void WriteToDisk(const Task& task,
281 SkStream* data, size_t len,
282 const SkBitmap* bitmap,
283 const char* ext) {
284 SkMD5 hash;
285 hash.writeStream(data, len);
286 SkMD5::Digest digest;
287 hash.finish(digest);
288
289 JsonWriter::BitmapResult result;
290 result.name = task.src->name();
291 result.config = task.sink.tag;
292 result.sourceType = task.src.tag;
293 result.ext = ext;
294 for (int i = 0; i < 16; i++) {
295 result.md5.appendf("%02x", digest.data[i]);
296 }
297 JsonWriter::AddBitmapResult(result);
298
299 const char* dir = FLAGS_writePath[0];
300 if (0 == strcmp(dir, "@")) { // Needed for iOS.
301 dir = FLAGS_resourcePath[0];
302 }
303 sk_mkdir(dir);
304
305 SkString path;
306 if (FLAGS_nameByHash) {
307 path = SkOSPath::Join(dir, result.md5.c_str());
308 path.append(".");
309 path.append(ext);
310 if (sk_exists(path.c_str())) {
311 return; // Content-addressed. If it exists already, we're done.
312 }
313 } else {
314 path = SkOSPath::Join(dir, task.sink.tag);
315 sk_mkdir(path.c_str());
316 path = SkOSPath::Join(path.c_str(), task.src.tag);
317 sk_mkdir(path.c_str());
318 path = SkOSPath::Join(path.c_str(), task.src->name().c_str());
319 path.append(".");
320 path.append(ext);
321 }
322
323 SkFILEWStream file(path.c_str());
324 if (!file.isValid()) {
325 fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str()));
326 return;
327 }
328
329 data->rewind();
330 if (bitmap) {
331 // We can't encode A8 bitmaps as PNGs. Convert them to 8888 first.
332 SkBitmap converted;
333 if (bitmap->info().colorType() == kAlpha_8_SkColorType) {
334 if (!bitmap->copyTo(&converted, kN32_SkColorType)) {
335 fail("Can't convert A8 to 8888.\n");
336 return;
337 }
338 bitmap = &converted;
339 }
340 if (!SkImageEncoder::EncodeStream(&file, *bitmap, SkImageEncoder::kPNG_Type, 100)) {
341 fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str()));
342 return;
343 }
344 } else {
345 if (!file.writeStream(data, len)) {
346 fail(SkStringPrintf("Can't write to %s.\n", path.c_str()));
347 return;
348 }
349 }
350 }
351};
352
353// Run all tasks in the same enclave serially on the same thread.
354// They can't possibly run concurrently with each other.
355static void run_enclave(SkTArray<Task>* tasks) {
356 for (int i = 0; i < tasks->count(); i++) {
357 Task::Run(tasks->begin() + i);
358 }
359}
360
361/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
362
363// Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
364
365static struct : public skiatest::Reporter {
366 void onReportFailed(const skiatest::Failure& failure) SK_OVERRIDE {
367 SkString s;
368 failure.getFailureString(&s);
369 fail(s);
370 JsonWriter::AddTestFailure(failure);
371 }
372 bool allowExtendedTest() const SK_OVERRIDE { return FLAGS_pathOpsExtended; }
373 bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; }
374} gTestReporter;
375
mtklein82d28432015-01-15 12:46:02 -0800376static SkTArray<SkAutoTDelete<skiatest::Test>, kMemcpyOK> gCPUTests, gGPUTests;
mtklein748ca3b2015-01-15 10:56:12 -0800377
378static void gather_tests() {
379 if (!FLAGS_tests) {
380 return;
381 }
382 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) {
383 SkAutoTDelete<skiatest::Test> test(r->factory()(NULL));
384 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) {
385 continue;
386 }
mtklein82d28432015-01-15 12:46:02 -0800387
mtklein748ca3b2015-01-15 10:56:12 -0800388 test->setReporter(&gTestReporter);
mtklein82d28432015-01-15 12:46:02 -0800389 if (test->isGPUTest() && gpu_supported()) {
390 gGPUTests.push_back().reset(test.detach());
391 } else if (!test->isGPUTest() && FLAGS_cpu) {
392 gCPUTests.push_back().reset(test.detach());
393 }
mtklein748ca3b2015-01-15 10:56:12 -0800394 }
395}
396
397static void run_test(SkAutoTDelete<skiatest::Test>* t) {
398 WallTimer timer;
399 timer.start();
400 skiatest::Test* test = t->get();
401 if (!FLAGS_dryRun) {
mtklein82d28432015-01-15 12:46:02 -0800402 test->setGrContextFactory(GetThreadLocalGrContextFactory());
mtklein748ca3b2015-01-15 10:56:12 -0800403 test->run();
404 if (!test->passed()) {
405 fail(SkStringPrintf("test %s failed", test->getName()));
406 }
407 }
408 timer.end();
409 done(timer.fWall, "unit", "test", test->getName());
410}
411
412/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
413
jcgregorio3b27ade2014-11-13 08:06:40 -0800414int dm_main();
caryclark17f0b6d2014-07-22 10:15:34 -0700415int dm_main() {
jcgregorio3b27ade2014-11-13 08:06:40 -0800416 SetupCrashHandler();
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +0000417 SkAutoGraphics ag;
mtklein406654b2014-09-03 15:34:37 -0700418 SkTaskGroup::Enabler enabled(FLAGS_threads);
commit-bot@chromium.orga65e2fd2014-05-30 17:23:31 +0000419
mtklein748ca3b2015-01-15 10:56:12 -0800420 gather_srcs();
421 gather_sinks();
422 gather_tests();
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +0000423
mtklein82d28432015-01-15 12:46:02 -0800424 gPending = gSrcs.count() * gSinks.count() + gCPUTests.count() + gGPUTests.count();
mtklein748ca3b2015-01-15 10:56:12 -0800425 SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n",
mtklein82d28432015-01-15 12:46:02 -0800426 gSrcs.count(), gSinks.count(), gCPUTests.count() + gGPUTests.count(), gPending);
mtklein748ca3b2015-01-15 10:56:12 -0800427
428 // We try to exploit as much parallelism as is safe. Most Src/Sink pairs run on any thread,
429 // but Sinks that identify as part of a particular enclave run serially on a single thread.
mtklein82d28432015-01-15 12:46:02 -0800430 // CPU tests run on any thread. GPU tests depend on --gpu_threading.
mtklein748ca3b2015-01-15 10:56:12 -0800431 SkTArray<Task> enclaves[kNumEnclaves];
432 for (int j = 0; j < gSinks.count(); j++) {
433 SkTArray<Task>& tasks = enclaves[gSinks[j]->enclave()];
434 for (int i = 0; i < gSrcs.count(); i++) {
435 tasks.push_back(Task(gSrcs[i], gSinks[j]));
436 }
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +0000437 }
438
mtklein748ca3b2015-01-15 10:56:12 -0800439 SK_COMPILE_ASSERT(kAnyThread_Enclave == 0, AnyThreadZero);
440 SkTaskGroup tg;
441 tg.batch( Task::Run, enclaves[0].begin(), enclaves[0].count());
442 tg.batch(run_enclave, enclaves+1, kNumEnclaves-1);
mtklein82d28432015-01-15 12:46:02 -0800443 tg.batch( run_test, gCPUTests.begin(), gCPUTests.count());
444 if (FLAGS_gpu_threading) {
445 tg.batch(run_test, gGPUTests.begin(), gGPUTests.count());
446 } else {
447 for (int i = 0; i < gGPUTests.count(); i++) {
448 run_test(&gGPUTests[i]);
449 }
450 }
mtklein748ca3b2015-01-15 10:56:12 -0800451 tg.wait();
kkinnunen80549fc2014-06-30 06:36:31 -0700452
mtklein748ca3b2015-01-15 10:56:12 -0800453 // At this point we're back in single-threaded land.
mtkleina2ef6422015-01-15 13:44:22 -0800454 SkDebugf("\n");
mtklein@google.comd36522d2013-10-16 13:02:15 +0000455
mtklein748ca3b2015-01-15 10:56:12 -0800456 JsonWriter::DumpJson();
457
458 if (gFailures.count() > 0) {
459 SkDebugf("Failures:\n");
460 for (int i = 0; i < gFailures.count(); i++) {
461 SkDebugf("\t%s", gFailures[i].c_str());
462 }
463 SkDebugf("%d failures\n", gFailures.count());
464 return 1;
mtklein114c3cd2015-01-15 10:15:02 -0800465 }
mtklein748ca3b2015-01-15 10:56:12 -0800466 if (gPending > 0) {
467 SkDebugf("Hrm, we didn't seem to run everything we intended to! Please file a bug.\n");
468 return 1;
mtklein114c3cd2015-01-15 10:15:02 -0800469 }
mtklein748ca3b2015-01-15 10:56:12 -0800470 return 0;
mtklein@google.comd36522d2013-10-16 13:02:15 +0000471}
jcgregorio3b27ade2014-11-13 08:06:40 -0800472
473#if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
474int main(int argc, char** argv) {
475 SkCommandLineFlags::Parse(argc, argv);
476 return dm_main();
477}
478#endif