blob: 0174b7314d3ab91bfa4a2ced1d12f138cb6a124c [file] [log] [blame]
scroggo478652e2015-03-25 07:11:02 -07001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
jcgregorio3b27ade2014-11-13 08:06:40 -08008#include "CrashHandler.h"
mtklein748ca3b2015-01-15 10:56:12 -08009#include "DMJsonWriter.h"
10#include "DMSrcSink.h"
tomhudsoneebc39a2015-02-23 12:18:05 -080011#include "DMSrcSinkAndroid.h"
mtklein748ca3b2015-01-15 10:56:12 -080012#include "OverwriteLine.h"
13#include "ProcStats.h"
14#include "SkBBHFactory.h"
mtklein62bd1a62015-01-27 14:46:26 -080015#include "SkChecksum.h"
caryclark17f0b6d2014-07-22 10:15:34 -070016#include "SkCommonFlags.h"
caryclark83ca6282015-06-10 09:31:09 -070017#include "SkFontMgr.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +000018#include "SkForceLinking.h"
19#include "SkGraphics.h"
mtkleine67164d2015-02-02 13:24:37 -080020#include "SkInstCnt.h"
mtklein748ca3b2015-01-15 10:56:12 -080021#include "SkMD5.h"
mtklein1d0f1642014-09-08 08:05:18 -070022#include "SkOSFile.h"
mtkleina82f5622015-02-20 12:30:19 -080023#include "SkTHash.h"
mtklein406654b2014-09-03 15:34:37 -070024#include "SkTaskGroup.h"
mtkleinde6fc2b2015-03-12 06:28:54 -070025#include "SkThreadUtils.h"
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000026#include "Test.h"
mtklein748ca3b2015-01-15 10:56:12 -080027#include "Timer.h"
caryclark83ca6282015-06-10 09:31:09 -070028#include "sk_tool_utils.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +000029
djsollen54416de2015-04-03 07:24:48 -070030DEFINE_string(src, "tests gm skp image", "Source types to test.");
mtklein748ca3b2015-01-15 10:56:12 -080031DEFINE_bool(nameByHash, false,
32 "If true, write to FLAGS_writePath[0]/<hash>.png instead of "
djsollen54416de2015-04-03 07:24:48 -070033 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>.png");
mtklein748ca3b2015-01-15 10:56:12 -080034DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
mtkleind603b222015-02-17 11:13:33 -080035DEFINE_string(matrix, "1 0 0 1",
36 "2x2 scale+skew matrix to apply or upright when using "
37 "'matrix' or 'upright' in config.");
mtklein82d28432015-01-15 12:46:02 -080038DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
mtklein@google.comd36522d2013-10-16 13:02:15 +000039
mtkleina2ef6422015-01-15 13:44:22 -080040DEFINE_string(blacklist, "",
djsollen54416de2015-04-03 07:24:48 -070041 "Space-separated config/src/srcOptions/name quadruples to blacklist. '_' matches anything. E.g. \n"
42 "'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu config.\n"
43 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aarects GM on 8888.");
mtkleina2ef6422015-01-15 13:44:22 -080044
mtklein62bd1a62015-01-27 14:46:26 -080045DEFINE_string2(readPath, r, "", "If set check for equality with golden results in this directory.");
46
borenet09ed4802015-04-03 14:15:33 -070047DEFINE_string(uninterestingHashesFile, "",
48 "File containing a list of uninteresting hashes. If a result hashes to something in "
49 "this list, no image is written for that result.");
50
mtklein6393c062015-04-27 08:45:01 -070051DEFINE_int32(shards, 1, "We're splitting source data into this many shards.");
52DEFINE_int32(shard, 0, "Which shard do I run?");
bsalomon821e10e2015-06-04 14:15:33 -070053DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
mtklein6393c062015-04-27 08:45:01 -070054
mtklein@google.comd36522d2013-10-16 13:02:15 +000055__SK_FORCE_IMAGE_DECODER_LINKING;
mtklein748ca3b2015-01-15 10:56:12 -080056using namespace DM;
mtklein@google.comd36522d2013-10-16 13:02:15 +000057
mtklein748ca3b2015-01-15 10:56:12 -080058/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
59
60SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
61static SkTArray<SkString> gFailures;
62
63static void fail(ImplicitString err) {
64 SkAutoMutexAcquire lock(gFailuresMutex);
65 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
66 gFailures.push_back(err);
halcanary9e398f72015-01-10 11:18:04 -080067}
68
mtkleinb37cb412015-03-18 05:27:14 -070069static int32_t gPending = 0; // Atomic. Total number of running and queued tasks.
70
71SK_DECLARE_STATIC_MUTEX(gRunningMutex);
72static SkTArray<SkString> gRunning;
mtklein748ca3b2015-01-15 10:56:12 -080073
mtkleinb9eb4ac2015-02-02 18:26:03 -080074static void done(double ms,
djsollen54416de2015-04-03 07:24:48 -070075 ImplicitString config, ImplicitString src, ImplicitString srcOptions,
76 ImplicitString name, ImplicitString note, ImplicitString log) {
77 SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(),
78 srcOptions.c_str(), name.c_str());
mtkleinb37cb412015-03-18 05:27:14 -070079 {
80 SkAutoMutexAcquire lock(gRunningMutex);
81 for (int i = 0; i < gRunning.count(); i++) {
82 if (gRunning[i] == id) {
83 gRunning.removeShuffle(i);
84 break;
85 }
86 }
87 }
88 if (!FLAGS_verbose) {
89 note = "";
90 }
mtkleinb9eb4ac2015-02-02 18:26:03 -080091 if (!log.isEmpty()) {
92 log.prepend("\n");
93 }
mtklein6dee2ad2015-02-05 09:53:44 -080094 auto pending = sk_atomic_dec(&gPending)-1;
reed50bc0512015-05-19 14:13:31 -070095 if (!FLAGS_quiet) {
96 SkDebugf("%s(%4d/%-4dMB %5d) %s\t%s%s%s", FLAGS_verbose ? "\n" : kSkOverwriteLine
97 , sk_tools::getCurrResidentSetSizeMB()
98 , sk_tools::getMaxResidentSetSizeMB()
99 , pending
100 , HumanizeMs(ms).c_str()
101 , id.c_str()
102 , note.c_str()
103 , log.c_str());
104 }
mtkleina17241b2015-01-23 05:48:00 -0800105 // We write our dm.json file every once in a while in case we crash.
106 // Notice this also handles the final dm.json when pending == 0.
107 if (pending % 500 == 0) {
108 JsonWriter::DumpJson();
109 }
mtklein@google.comd36522d2013-10-16 13:02:15 +0000110}
111
djsollen54416de2015-04-03 07:24:48 -0700112static void start(ImplicitString config, ImplicitString src,
113 ImplicitString srcOptions, ImplicitString name) {
114 SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(),
115 srcOptions.c_str(), name.c_str());
mtkleinb37cb412015-03-18 05:27:14 -0700116 SkAutoMutexAcquire lock(gRunningMutex);
117 gRunning.push_back(id);
118}
119
mtklein748ca3b2015-01-15 10:56:12 -0800120/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
mtklein114c3cd2015-01-15 10:15:02 -0800121
mtklein62bd1a62015-01-27 14:46:26 -0800122struct Gold : public SkString {
mtkleina82f5622015-02-20 12:30:19 -0800123 Gold() : SkString("") {}
djsollen54416de2015-04-03 07:24:48 -0700124 Gold(ImplicitString sink, ImplicitString src, ImplicitString srcOptions,
125 ImplicitString name, ImplicitString md5)
mtklein62bd1a62015-01-27 14:46:26 -0800126 : SkString("") {
127 this->append(sink);
128 this->append(src);
djsollen54416de2015-04-03 07:24:48 -0700129 this->append(srcOptions);
mtklein62bd1a62015-01-27 14:46:26 -0800130 this->append(name);
131 this->append(md5);
mtklein62bd1a62015-01-27 14:46:26 -0800132 }
mtklein02f46cf2015-03-20 13:48:42 -0700133 static uint32_t Hash(const Gold& g) { return SkGoodHash((const SkString&)g); }
mtklein62bd1a62015-01-27 14:46:26 -0800134};
mtkleina82f5622015-02-20 12:30:19 -0800135static SkTHashSet<Gold, Gold::Hash> gGold;
mtklein62bd1a62015-01-27 14:46:26 -0800136
137static void add_gold(JsonWriter::BitmapResult r) {
djsollen54416de2015-04-03 07:24:48 -0700138 gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5));
mtklein62bd1a62015-01-27 14:46:26 -0800139}
140
141static void gather_gold() {
142 if (!FLAGS_readPath.isEmpty()) {
143 SkString path(FLAGS_readPath[0]);
144 path.append("/dm.json");
145 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) {
146 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_str()));
147 }
148 }
149}
150
151/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
152
borenet09ed4802015-04-03 14:15:33 -0700153static SkTHashSet<SkString> gUninterestingHashes;
154
155static void gather_uninteresting_hashes() {
156 if (!FLAGS_uninterestingHashesFile.isEmpty()) {
157 SkAutoTUnref<SkData> data(SkData::NewFromFileName(FLAGS_uninterestingHashesFile[0]));
158 SkTArray<SkString> hashes;
159 SkStrSplit((const char*)data->data(), "\n", &hashes);
160 for (const SkString& hash : hashes) {
161 gUninterestingHashes.add(hash);
162 }
163 }
164}
165
166/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
167
mtklein748ca3b2015-01-15 10:56:12 -0800168template <typename T>
djsollen54416de2015-04-03 07:24:48 -0700169struct Tagged : public SkAutoTDelete<T> {
170 const char* tag;
171 const char* options;
172};
mtklein748ca3b2015-01-15 10:56:12 -0800173
174static const bool kMemcpyOK = true;
175
176static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs;
177static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks;
178
mtklein6393c062015-04-27 08:45:01 -0700179static bool in_shard() {
180 static int N = 0;
181 return N++ % FLAGS_shards == FLAGS_shard;
182}
183
djsollen54416de2015-04-03 07:24:48 -0700184static void push_src(const char* tag, const char* options, Src* s) {
mtklein748ca3b2015-01-15 10:56:12 -0800185 SkAutoTDelete<Src> src(s);
mtklein6393c062015-04-27 08:45:01 -0700186 if (in_shard() &&
187 FLAGS_src.contains(tag) &&
mtklein748ca3b2015-01-15 10:56:12 -0800188 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
189 Tagged<Src>& s = gSrcs.push_back();
190 s.reset(src.detach());
191 s.tag = tag;
djsollen54416de2015-04-03 07:24:48 -0700192 s.options = options;
mtklein114c3cd2015-01-15 10:15:02 -0800193 }
mtklein748ca3b2015-01-15 10:56:12 -0800194}
mtklein114c3cd2015-01-15 10:15:02 -0800195
msarett438b2ad2015-04-09 12:43:10 -0700196static void push_codec_srcs(Path path) {
197 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
198 if (!encoded) {
199 SkDebugf("Couldn't read %s.", path.c_str());
200 return;
201 }
202 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
203 if (NULL == codec.get()) {
204 SkDebugf("Couldn't create codec for %s.", path.c_str());
205 return;
206 }
207
208 // Build additional test cases for images that decode natively to non-canvas types
209 switch(codec->getInfo().colorType()) {
210 case kGray_8_SkColorType:
djsollena669bc32015-04-14 13:47:51 -0700211 push_src("image", "codec_kGray8", new CodecSrc(path, CodecSrc::kNormal_Mode,
msarett438b2ad2015-04-09 12:43:10 -0700212 CodecSrc::kGrayscale_Always_DstColorType));
djsollena669bc32015-04-14 13:47:51 -0700213 push_src("image", "scanline_kGray8", new CodecSrc(path, CodecSrc::kScanline_Mode,
msarett438b2ad2015-04-09 12:43:10 -0700214 CodecSrc::kGrayscale_Always_DstColorType));
emmaleer97002062015-05-27 12:36:10 -0700215 push_src("image", "scanline_subset_kGray8", new CodecSrc(path,
216 CodecSrc::kScanline_Subset_Mode, CodecSrc::kGrayscale_Always_DstColorType));
msarett438b2ad2015-04-09 12:43:10 -0700217 // Intentional fall through
218 // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8?
219 // Further discussion on this topic is at skbug.com/3683
emmaleer97002062015-05-27 12:36:10 -0700220 case kIndex_8_SkColorType:
221 push_src("image", "codec_kIndex8", new CodecSrc(path, CodecSrc::kNormal_Mode,
222 CodecSrc::kIndex8_Always_DstColorType));
223 push_src("image", "scanline_kIndex8", new CodecSrc(path, CodecSrc::kScanline_Mode,
224 CodecSrc::kIndex8_Always_DstColorType));
225 push_src("image", "scanline_subset_kIndex8", new CodecSrc(path,
226 CodecSrc::kScanline_Subset_Mode, CodecSrc::kIndex8_Always_DstColorType));
227 break;
228 default:
229 // Do nothing
230 break;
msarett438b2ad2015-04-09 12:43:10 -0700231 }
232
233 // Decode all images to the canvas color type
234 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode,
235 CodecSrc::kGetFromCanvas_DstColorType));
236 push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mode,
237 CodecSrc::kGetFromCanvas_DstColorType));
emmaleer97002062015-05-27 12:36:10 -0700238 push_src("image", "scanline_subset", new CodecSrc(path, CodecSrc::kScanline_Subset_Mode,
239 CodecSrc::kGetFromCanvas_DstColorType));
msarett438b2ad2015-04-09 12:43:10 -0700240}
241
scroggo9b77ddd2015-03-19 06:03:39 -0700242static bool codec_supported(const char* ext) {
243 // FIXME: Once other versions of SkCodec are available, we can add them to this
244 // list (and eventually we can remove this check once they are all supported).
msarett8c8f22a2015-04-01 06:58:48 -0700245 static const char* const exts[] = {
msarette16b04a2015-04-15 07:32:19 -0700246 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp",
247 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP"
msarett8c8f22a2015-04-01 06:58:48 -0700248 };
249
250 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
251 if (0 == strcmp(exts[i], ext)) {
252 return true;
253 }
254 }
255 return false;
scroggo9b77ddd2015-03-19 06:03:39 -0700256}
257
mtklein748ca3b2015-01-15 10:56:12 -0800258static void gather_srcs() {
259 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) {
djsollen54416de2015-04-03 07:24:48 -0700260 push_src("gm", "", new GMSrc(r->factory()));
mtklein748ca3b2015-01-15 10:56:12 -0800261 }
halcanaryfc37ad12015-01-30 07:31:19 -0800262 for (int i = 0; i < FLAGS_skps.count(); i++) {
263 const char* path = FLAGS_skps[i];
264 if (sk_isdir(path)) {
265 SkOSFile::Iter it(path, "skp");
266 for (SkString file; it.next(&file); ) {
djsollen54416de2015-04-03 07:24:48 -0700267 push_src("skp", "", new SKPSrc(SkOSPath::Join(path, file.c_str())));
halcanaryfc37ad12015-01-30 07:31:19 -0800268 }
269 } else {
djsollen54416de2015-04-03 07:24:48 -0700270 push_src("skp", "", new SKPSrc(path));
mtklein114c3cd2015-01-15 10:15:02 -0800271 }
272 }
halcanary23b03c32015-01-30 09:58:58 -0800273 static const char* const exts[] = {
274 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
275 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
276 };
277 for (int i = 0; i < FLAGS_images.count(); i++) {
278 const char* flag = FLAGS_images[i];
279 if (sk_isdir(flag)) {
280 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) {
281 SkOSFile::Iter it(flag, exts[j]);
282 for (SkString file; it.next(&file); ) {
283 SkString path = SkOSPath::Join(flag, file.c_str());
djsollen54416de2015-04-03 07:24:48 -0700284 push_src("image", "decode", new ImageSrc(path)); // Decode entire image
285 push_src("image", "subset", new ImageSrc(path, 2)); // Decode into 2x2 subsets
scroggo9b77ddd2015-03-19 06:03:39 -0700286 if (codec_supported(exts[j])) {
msarett438b2ad2015-04-09 12:43:10 -0700287 push_codec_srcs(path);
scroggo9b77ddd2015-03-19 06:03:39 -0700288 }
halcanary23b03c32015-01-30 09:58:58 -0800289 }
mtklein114c3cd2015-01-15 10:15:02 -0800290 }
halcanary23b03c32015-01-30 09:58:58 -0800291 } else if (sk_exists(flag)) {
292 // assume that FLAGS_images[i] is a valid image if it is a file.
djsollen54416de2015-04-03 07:24:48 -0700293 push_src("image", "decode", new ImageSrc(flag)); // Decode entire image.
294 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets
msarett438b2ad2015-04-09 12:43:10 -0700295 push_codec_srcs(flag);
mtklein709d2c32015-01-15 08:30:25 -0800296 }
mtklein709d2c32015-01-15 08:30:25 -0800297 }
298}
299
mtklein748ca3b2015-01-15 10:56:12 -0800300static GrGLStandard get_gpu_api() {
301 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; }
302 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; }
303 return kNone_GrGLStandard;
mtklein709d2c32015-01-15 08:30:25 -0800304}
305
mtklein748ca3b2015-01-15 10:56:12 -0800306static void push_sink(const char* tag, Sink* s) {
307 SkAutoTDelete<Sink> sink(s);
308 if (!FLAGS_config.contains(tag)) {
309 return;
mtklein114c3cd2015-01-15 10:15:02 -0800310 }
mtklein748ca3b2015-01-15 10:56:12 -0800311 // Try a noop Src as a canary. If it fails, skip this sink.
312 struct : public Src {
mtklein36352bf2015-03-25 18:17:31 -0700313 Error draw(SkCanvas*) const override { return ""; }
314 SkISize size() const override { return SkISize::Make(16, 16); }
315 Name name() const override { return "noop"; }
mtklein748ca3b2015-01-15 10:56:12 -0800316 } noop;
mtklein114c3cd2015-01-15 10:15:02 -0800317
mtklein748ca3b2015-01-15 10:56:12 -0800318 SkBitmap bitmap;
319 SkDynamicMemoryWStream stream;
mtkleinb9eb4ac2015-02-02 18:26:03 -0800320 SkString log;
321 Error err = sink->draw(noop, &bitmap, &stream, &log);
mtklein4089ef72015-03-05 08:40:28 -0800322 if (err.isFatal()) {
mtklein05641a52015-04-21 10:49:13 -0700323 SkDebugf("Could not run %s: %s\n", tag, err.c_str());
324 exit(1);
mtklein114c3cd2015-01-15 10:15:02 -0800325 }
326
mtklein748ca3b2015-01-15 10:56:12 -0800327 Tagged<Sink>& ts = gSinks.push_back();
328 ts.reset(sink.detach());
329 ts.tag = tag;
330}
331
332static bool gpu_supported() {
333#if SK_SUPPORT_GPU
334 return FLAGS_gpu;
335#else
336 return false;
337#endif
338}
339
340static Sink* create_sink(const char* tag) {
341#define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); }
342 if (gpu_supported()) {
mtklein82d28432015-01-15 12:46:02 -0800343 typedef GrContextFactory Gr;
mtklein748ca3b2015-01-15 10:56:12 -0800344 const GrGLStandard api = get_gpu_api();
mtklein82d28432015-01-15 12:46:02 -0800345 SINK("gpunull", GPUSink, Gr::kNull_GLContextType, api, 0, false, FLAGS_gpu_threading);
346 SINK("gpudebug", GPUSink, Gr::kDebug_GLContextType, api, 0, false, FLAGS_gpu_threading);
347 SINK("gpu", GPUSink, Gr::kNative_GLContextType, api, 0, false, FLAGS_gpu_threading);
348 SINK("gpudft", GPUSink, Gr::kNative_GLContextType, api, 0, true, FLAGS_gpu_threading);
349 SINK("msaa4", GPUSink, Gr::kNative_GLContextType, api, 4, false, FLAGS_gpu_threading);
350 SINK("msaa16", GPUSink, Gr::kNative_GLContextType, api, 16, false, FLAGS_gpu_threading);
351 SINK("nvprmsaa4", GPUSink, Gr::kNVPR_GLContextType, api, 4, false, FLAGS_gpu_threading);
352 SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, false, FLAGS_gpu_threading);
mtklein748ca3b2015-01-15 10:56:12 -0800353 #if SK_ANGLE
mtklein82d28432015-01-15 12:46:02 -0800354 SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading);
mtklein748ca3b2015-01-15 10:56:12 -0800355 #endif
356 #if SK_MESA
mtklein82d28432015-01-15 12:46:02 -0800357 SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0, false, FLAGS_gpu_threading);
mtklein748ca3b2015-01-15 10:56:12 -0800358 #endif
mtklein114c3cd2015-01-15 10:15:02 -0800359 }
mtklein748ca3b2015-01-15 10:56:12 -0800360
tomhudsoneebc39a2015-02-23 12:18:05 -0800361#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
362 SINK("hwui", HWUISink);
363#endif
364
mtklein748ca3b2015-01-15 10:56:12 -0800365 if (FLAGS_cpu) {
366 SINK("565", RasterSink, kRGB_565_SkColorType);
367 SINK("8888", RasterSink, kN32_SkColorType);
mtklein19f30602015-01-20 13:34:39 -0800368 SINK("pdf", PDFSink);
mtklein9c3f17d2015-01-28 11:35:18 -0800369 SINK("skp", SKPSink);
mtklein8a4527e2015-01-31 20:00:58 -0800370 SINK("svg", SVGSink);
371 SINK("null", NullSink);
halcanary47ef4d52015-03-03 09:13:09 -0800372 SINK("xps", XPSSink);
mtklein748ca3b2015-01-15 10:56:12 -0800373 }
374#undef SINK
375 return NULL;
mtklein114c3cd2015-01-15 10:15:02 -0800376}
377
mtklein748ca3b2015-01-15 10:56:12 -0800378static Sink* create_via(const char* tag, Sink* wrapped) {
379#define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__); }
mtklein6fbf4b32015-05-06 11:35:40 -0700380 VIA("twice", ViaTwice, wrapped);
mtklein7edca212015-01-21 13:18:51 -0800381 VIA("pipe", ViaPipe, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800382 VIA("serialize", ViaSerialization, wrapped);
reed06a22f62015-05-05 08:11:33 -0700383 VIA("deferred", ViaDeferred, wrapped);
mtkleinb7e8d692015-04-07 08:30:32 -0700384 VIA("2ndpic", ViaSecondPicture, wrapped);
mtkleind31c13d2015-05-05 12:59:56 -0700385 VIA("sp", ViaSingletonPictures, wrapped);
mtklein7edca212015-01-21 13:18:51 -0800386 VIA("tiles", ViaTiles, 256, 256, NULL, wrapped);
387 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800388
mtkleind603b222015-02-17 11:13:33 -0800389 if (FLAGS_matrix.count() == 4) {
mtklein748ca3b2015-01-15 10:56:12 -0800390 SkMatrix m;
mtkleind603b222015-02-17 11:13:33 -0800391 m.reset();
392 m.setScaleX((SkScalar)atof(FLAGS_matrix[0]));
393 m.setSkewX ((SkScalar)atof(FLAGS_matrix[1]));
394 m.setSkewY ((SkScalar)atof(FLAGS_matrix[2]));
395 m.setScaleY((SkScalar)atof(FLAGS_matrix[3]));
396 VIA("matrix", ViaMatrix, m, wrapped);
397 VIA("upright", ViaUpright, m, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800398 }
tomhudson64de1e12015-03-05 08:01:07 -0800399
400#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
401 VIA("androidsdk", ViaAndroidSDK, wrapped);
402#endif
403
mtklein748ca3b2015-01-15 10:56:12 -0800404#undef VIA
405 return NULL;
mtklein114c3cd2015-01-15 10:15:02 -0800406}
407
mtklein748ca3b2015-01-15 10:56:12 -0800408static void gather_sinks() {
409 for (int i = 0; i < FLAGS_config.count(); i++) {
410 const char* config = FLAGS_config[i];
411 SkTArray<SkString> parts;
412 SkStrSplit(config, "-", &parts);
413
414 Sink* sink = NULL;
415 for (int i = parts.count(); i-- > 0;) {
416 const char* part = parts[i].c_str();
417 Sink* next = (sink == NULL) ? create_sink(part) : create_via(part, sink);
418 if (next == NULL) {
419 SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part);
420 delete sink;
421 sink = NULL;
422 break;
423 }
424 sink = next;
425 }
426 if (sink) {
427 push_sink(config, sink);
mtklein114c3cd2015-01-15 10:15:02 -0800428 }
429 }
430}
mtklein709d2c32015-01-15 08:30:25 -0800431
mtkleina2ef6422015-01-15 13:44:22 -0800432static bool match(const char* needle, const char* haystack) {
433 return 0 == strcmp("_", needle) || NULL != strstr(haystack, needle);
434}
435
djsollen54416de2015-04-03 07:24:48 -0700436static ImplicitString is_blacklisted(const char* sink, const char* src,
437 const char* srcOptions, const char* name) {
mtklein0d243ff2015-04-03 07:51:00 -0700438 for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) {
mtkleina2ef6422015-01-15 13:44:22 -0800439 if (match(FLAGS_blacklist[i+0], sink) &&
djsollen54416de2015-04-03 07:24:48 -0700440 match(FLAGS_blacklist[i+1], src) &&
441 match(FLAGS_blacklist[i+2], srcOptions) &&
442 match(FLAGS_blacklist[i+3], name)) {
443 return SkStringPrintf("%s %s %s %s",
444 FLAGS_blacklist[i+0], FLAGS_blacklist[i+1],
445 FLAGS_blacklist[i+2], FLAGS_blacklist[i+3]);
mtkleina2ef6422015-01-15 13:44:22 -0800446 }
447 }
448 return "";
449}
450
mtklein748ca3b2015-01-15 10:56:12 -0800451// The finest-grained unit of work we can run: draw a single Src into a single Sink,
452// report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream.
453struct Task {
454 Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink) {}
455 const Tagged<Src>& src;
456 const Tagged<Sink>& sink;
457
458 static void Run(Task* task) {
mtkleina2ef6422015-01-15 13:44:22 -0800459 SkString name = task->src->name();
mtkleinb37cb412015-03-18 05:27:14 -0700460 SkString note;
djsollen54416de2015-04-03 07:24:48 -0700461 SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag,
462 task->src.options, name.c_str());
mtkleinb37cb412015-03-18 05:27:14 -0700463 if (!whyBlacklisted.isEmpty()) {
464 note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
465 }
mtkleinb9eb4ac2015-02-02 18:26:03 -0800466 SkString log;
mtklein748ca3b2015-01-15 10:56:12 -0800467 WallTimer timer;
468 timer.start();
mtkleina2ef6422015-01-15 13:44:22 -0800469 if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) {
mtklein748ca3b2015-01-15 10:56:12 -0800470 SkBitmap bitmap;
471 SkDynamicMemoryWStream stream;
bsalomon821e10e2015-06-04 14:15:33 -0700472 if (FLAGS_pre_log) {
473 SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag);
474 }
djsollen54416de2015-04-03 07:24:48 -0700475 start(task->sink.tag, task->src.tag, task->src.options, name.c_str());
mtkleinb9eb4ac2015-02-02 18:26:03 -0800476 Error err = task->sink->draw(*task->src, &bitmap, &stream, &log);
mtklein748ca3b2015-01-15 10:56:12 -0800477 if (!err.isEmpty()) {
mtklein4089ef72015-03-05 08:40:28 -0800478 timer.end();
479 if (err.isFatal()) {
djsollen54416de2015-04-03 07:24:48 -0700480 fail(SkStringPrintf("%s %s %s %s: %s",
mtklein4089ef72015-03-05 08:40:28 -0800481 task->sink.tag,
482 task->src.tag,
djsollen54416de2015-04-03 07:24:48 -0700483 task->src.options,
mtklein4089ef72015-03-05 08:40:28 -0800484 name.c_str(),
485 err.c_str()));
mtkleinb37cb412015-03-18 05:27:14 -0700486 } else {
487 note.appendf(" (skipped: %s)", err.c_str());
mtklein4089ef72015-03-05 08:40:28 -0800488 }
djsollen54416de2015-04-03 07:24:48 -0700489 done(timer.fWall, task->sink.tag, task->src.tag, task->src.options,
490 name, note, log);
mtklein4089ef72015-03-05 08:40:28 -0800491 return;
mtklein748ca3b2015-01-15 10:56:12 -0800492 }
mtklein62bd1a62015-01-27 14:46:26 -0800493 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream());
494
495 SkString md5;
496 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
497 SkMD5 hash;
498 if (data->getLength()) {
499 hash.writeStream(data, data->getLength());
500 data->rewind();
501 } else {
502 hash.write(bitmap.getPixels(), bitmap.getSize());
503 }
504 SkMD5::Digest digest;
505 hash.finish(digest);
506 for (int i = 0; i < 16; i++) {
507 md5.appendf("%02x", digest.data[i]);
508 }
509 }
510
511 if (!FLAGS_readPath.isEmpty() &&
djsollen54416de2015-04-03 07:24:48 -0700512 !gGold.contains(Gold(task->sink.tag, task->src.tag,
513 task->src.options, name, md5))) {
514 fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
mtklein62bd1a62015-01-27 14:46:26 -0800515 md5.c_str(),
516 task->sink.tag,
517 task->src.tag,
djsollen54416de2015-04-03 07:24:48 -0700518 task->src.options,
mtklein62bd1a62015-01-27 14:46:26 -0800519 name.c_str(),
520 FLAGS_readPath[0]));
521 }
522
mtkleinb0531a72015-04-07 13:38:48 -0700523 if (!FLAGS_writePath.isEmpty()) {
mtklein748ca3b2015-01-15 10:56:12 -0800524 const char* ext = task->sink->fileExtension();
mtklein62bd1a62015-01-27 14:46:26 -0800525 if (data->getLength()) {
526 WriteToDisk(*task, md5, ext, data, data->getLength(), NULL);
halcanary022afb82015-01-30 11:00:12 -0800527 SkASSERT(bitmap.drawsNothing());
528 } else if (!bitmap.drawsNothing()) {
mtklein62bd1a62015-01-27 14:46:26 -0800529 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap);
mtklein748ca3b2015-01-15 10:56:12 -0800530 }
531 }
532 }
533 timer.end();
djsollen54416de2015-04-03 07:24:48 -0700534 done(timer.fWall, task->sink.tag, task->src.tag, task->src.options, name, note, log);
mtklein748ca3b2015-01-15 10:56:12 -0800535 }
536
537 static void WriteToDisk(const Task& task,
mtklein62bd1a62015-01-27 14:46:26 -0800538 SkString md5,
539 const char* ext,
mtklein748ca3b2015-01-15 10:56:12 -0800540 SkStream* data, size_t len,
mtklein62bd1a62015-01-27 14:46:26 -0800541 const SkBitmap* bitmap) {
mtklein748ca3b2015-01-15 10:56:12 -0800542 JsonWriter::BitmapResult result;
djsollen54416de2015-04-03 07:24:48 -0700543 result.name = task.src->name();
544 result.config = task.sink.tag;
545 result.sourceType = task.src.tag;
546 result.sourceOptions = task.src.options;
547 result.ext = ext;
548 result.md5 = md5;
mtklein748ca3b2015-01-15 10:56:12 -0800549 JsonWriter::AddBitmapResult(result);
550
mtkleinb0531a72015-04-07 13:38:48 -0700551 // If an MD5 is uninteresting, we want it noted in the JSON file,
552 // but don't want to dump it out as a .png (or whatever ext is).
553 if (gUninterestingHashes.contains(md5)) {
554 return;
555 }
556
mtklein748ca3b2015-01-15 10:56:12 -0800557 const char* dir = FLAGS_writePath[0];
558 if (0 == strcmp(dir, "@")) { // Needed for iOS.
559 dir = FLAGS_resourcePath[0];
560 }
561 sk_mkdir(dir);
562
563 SkString path;
564 if (FLAGS_nameByHash) {
565 path = SkOSPath::Join(dir, result.md5.c_str());
566 path.append(".");
567 path.append(ext);
568 if (sk_exists(path.c_str())) {
569 return; // Content-addressed. If it exists already, we're done.
570 }
571 } else {
572 path = SkOSPath::Join(dir, task.sink.tag);
573 sk_mkdir(path.c_str());
574 path = SkOSPath::Join(path.c_str(), task.src.tag);
575 sk_mkdir(path.c_str());
djsollen54416de2015-04-03 07:24:48 -0700576 if (strcmp(task.src.options, "") != 0) {
577 path = SkOSPath::Join(path.c_str(), task.src.options);
578 sk_mkdir(path.c_str());
579 }
mtklein748ca3b2015-01-15 10:56:12 -0800580 path = SkOSPath::Join(path.c_str(), task.src->name().c_str());
581 path.append(".");
582 path.append(ext);
583 }
584
585 SkFILEWStream file(path.c_str());
586 if (!file.isValid()) {
587 fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str()));
588 return;
589 }
590
mtklein748ca3b2015-01-15 10:56:12 -0800591 if (bitmap) {
592 // We can't encode A8 bitmaps as PNGs. Convert them to 8888 first.
593 SkBitmap converted;
594 if (bitmap->info().colorType() == kAlpha_8_SkColorType) {
595 if (!bitmap->copyTo(&converted, kN32_SkColorType)) {
596 fail("Can't convert A8 to 8888.\n");
597 return;
598 }
599 bitmap = &converted;
600 }
601 if (!SkImageEncoder::EncodeStream(&file, *bitmap, SkImageEncoder::kPNG_Type, 100)) {
602 fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str()));
603 return;
604 }
605 } else {
606 if (!file.writeStream(data, len)) {
607 fail(SkStringPrintf("Can't write to %s.\n", path.c_str()));
608 return;
609 }
610 }
611 }
612};
613
614// Run all tasks in the same enclave serially on the same thread.
615// They can't possibly run concurrently with each other.
616static void run_enclave(SkTArray<Task>* tasks) {
617 for (int i = 0; i < tasks->count(); i++) {
618 Task::Run(tasks->begin() + i);
619 }
620}
621
622/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
623
624// Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
625
mtklein55e88b22015-01-21 15:50:13 -0800626static SkTDArray<skiatest::Test> gThreadedTests, gGPUTests;
mtklein748ca3b2015-01-15 10:56:12 -0800627
628static void gather_tests() {
mtklein6c5fed22015-01-20 13:47:23 -0800629 if (!FLAGS_src.contains("tests")) {
mtklein748ca3b2015-01-15 10:56:12 -0800630 return;
631 }
mtklein6393c062015-04-27 08:45:01 -0700632 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) {
633 if (!in_shard()) {
634 continue;
635 }
halcanary87f3ba42015-01-20 09:30:20 -0800636 // Despite its name, factory() is returning a reference to
637 // link-time static const POD data.
638 const skiatest::Test& test = r->factory();
639 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) {
mtklein748ca3b2015-01-15 10:56:12 -0800640 continue;
641 }
halcanary87f3ba42015-01-20 09:30:20 -0800642 if (test.needsGpu && gpu_supported()) {
mtklein55e88b22015-01-21 15:50:13 -0800643 (FLAGS_gpu_threading ? gThreadedTests : gGPUTests).push(test);
halcanary87f3ba42015-01-20 09:30:20 -0800644 } else if (!test.needsGpu && FLAGS_cpu) {
mtklein55e88b22015-01-21 15:50:13 -0800645 gThreadedTests.push(test);
mtklein82d28432015-01-15 12:46:02 -0800646 }
mtklein748ca3b2015-01-15 10:56:12 -0800647 }
648}
649
halcanary87f3ba42015-01-20 09:30:20 -0800650static void run_test(skiatest::Test* test) {
651 struct : public skiatest::Reporter {
mtklein36352bf2015-03-25 18:17:31 -0700652 void reportFailed(const skiatest::Failure& failure) override {
halcanary87f3ba42015-01-20 09:30:20 -0800653 fail(failure.toString());
654 JsonWriter::AddTestFailure(failure);
655 }
mtklein36352bf2015-03-25 18:17:31 -0700656 bool allowExtendedTest() const override {
halcanary87f3ba42015-01-20 09:30:20 -0800657 return FLAGS_pathOpsExtended;
658 }
mtklein36352bf2015-03-25 18:17:31 -0700659 bool verbose() const override { return FLAGS_veryVerbose; }
halcanary87f3ba42015-01-20 09:30:20 -0800660 } reporter;
mtklein748ca3b2015-01-15 10:56:12 -0800661 WallTimer timer;
662 timer.start();
mtklein748ca3b2015-01-15 10:56:12 -0800663 if (!FLAGS_dryRun) {
djsollen54416de2015-04-03 07:24:48 -0700664 start("unit", "test", "", test->name);
mtklein55e88b22015-01-21 15:50:13 -0800665 GrContextFactory factory;
bsalomon821e10e2015-06-04 14:15:33 -0700666 if (FLAGS_pre_log) {
667 SkDebugf("\nRunning test %s", test->name);
668 }
mtklein55e88b22015-01-21 15:50:13 -0800669 test->proc(&reporter, &factory);
mtklein748ca3b2015-01-15 10:56:12 -0800670 }
671 timer.end();
djsollen54416de2015-04-03 07:24:48 -0700672 done(timer.fWall, "unit", "test", "", test->name, "", "");
mtklein748ca3b2015-01-15 10:56:12 -0800673}
674
675/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
676
mtklein55e88b22015-01-21 15:50:13 -0800677// If we're isolating all GPU-bound work to one thread (the default), this function runs all that.
678static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) {
679 run_enclave(tasks);
680 for (int i = 0; i < gGPUTests.count(); i++) {
681 run_test(&gGPUTests[i]);
682 }
683}
684
mtkleinde6fc2b2015-03-12 06:28:54 -0700685// Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've hung.
686// This prints something every once in a while so that it knows we're still working.
mtklein2e1c47e2015-03-12 07:16:56 -0700687static void start_keepalive() {
688 struct Loop {
689 static void forever(void*) {
690 for (;;) {
691 static const int kSec = 300;
692 #if defined(SK_BUILD_FOR_WIN)
693 Sleep(kSec * 1000);
694 #else
695 sleep(kSec);
696 #endif
mtkleinb37cb412015-03-18 05:27:14 -0700697 SkString running;
698 {
699 SkAutoMutexAcquire lock(gRunningMutex);
700 for (int i = 0; i < gRunning.count(); i++) {
701 running.appendf("\n\t%s", gRunning[i].c_str());
702 }
703 }
704 SkDebugf("\nCurrently running:%s\n", running.c_str());
mtklein2e1c47e2015-03-12 07:16:56 -0700705 }
706 }
707 };
708 static SkThread* intentionallyLeaked = new SkThread(Loop::forever);
709 intentionallyLeaked->start();
mtkleinde6fc2b2015-03-12 06:28:54 -0700710}
711
caryclark83ca6282015-06-10 09:31:09 -0700712#define PORTABLE_FONT_PREFIX "Toy Liberation "
713
714static SkTypeface* create_from_name(const char familyName[], SkTypeface::Style style) {
715 if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX)
716 && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_PREFIX) - 1)) {
717 return sk_tool_utils::create_portable_typeface_always(familyName, style);
718 }
719 return NULL;
720}
721
722#undef PORTABLE_FONT_PREFIX
723
724extern SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style );
725
jcgregorio3b27ade2014-11-13 08:06:40 -0800726int dm_main();
caryclark17f0b6d2014-07-22 10:15:34 -0700727int dm_main() {
jcgregorio3b27ade2014-11-13 08:06:40 -0800728 SetupCrashHandler();
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +0000729 SkAutoGraphics ag;
mtklein406654b2014-09-03 15:34:37 -0700730 SkTaskGroup::Enabler enabled(FLAGS_threads);
mtkleine67164d2015-02-02 13:24:37 -0800731 if (FLAGS_leaks) {
732 SkInstCountPrintLeaksOnExit();
733 }
caryclark83ca6282015-06-10 09:31:09 -0700734 gCreateTypefaceDelegate = &create_from_name;
commit-bot@chromium.orga65e2fd2014-05-30 17:23:31 +0000735
mtklein2e1c47e2015-03-12 07:16:56 -0700736 start_keepalive();
mtkleinde6fc2b2015-03-12 06:28:54 -0700737
mtklein62bd1a62015-01-27 14:46:26 -0800738 gather_gold();
borenet09ed4802015-04-03 14:15:33 -0700739 gather_uninteresting_hashes();
mtklein62bd1a62015-01-27 14:46:26 -0800740
mtklein748ca3b2015-01-15 10:56:12 -0800741 gather_srcs();
742 gather_sinks();
743 gather_tests();
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +0000744
mtklein55e88b22015-01-21 15:50:13 -0800745 gPending = gSrcs.count() * gSinks.count() + gThreadedTests.count() + gGPUTests.count();
mtklein748ca3b2015-01-15 10:56:12 -0800746 SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n",
mtklein55e88b22015-01-21 15:50:13 -0800747 gSrcs.count(), gSinks.count(), gThreadedTests.count() + gGPUTests.count(), gPending);
mtklein748ca3b2015-01-15 10:56:12 -0800748
749 // We try to exploit as much parallelism as is safe. Most Src/Sink pairs run on any thread,
750 // but Sinks that identify as part of a particular enclave run serially on a single thread.
mtklein82d28432015-01-15 12:46:02 -0800751 // CPU tests run on any thread. GPU tests depend on --gpu_threading.
mtklein748ca3b2015-01-15 10:56:12 -0800752 SkTArray<Task> enclaves[kNumEnclaves];
753 for (int j = 0; j < gSinks.count(); j++) {
754 SkTArray<Task>& tasks = enclaves[gSinks[j]->enclave()];
755 for (int i = 0; i < gSrcs.count(); i++) {
756 tasks.push_back(Task(gSrcs[i], gSinks[j]));
757 }
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +0000758 }
759
mtklein748ca3b2015-01-15 10:56:12 -0800760 SkTaskGroup tg;
mtklein55e88b22015-01-21 15:50:13 -0800761 tg.batch(run_test, gThreadedTests.begin(), gThreadedTests.count());
762 for (int i = 0; i < kNumEnclaves; i++) {
763 switch(i) {
764 case kAnyThread_Enclave:
765 tg.batch(Task::Run, enclaves[i].begin(), enclaves[i].count());
766 break;
767 case kGPU_Enclave:
768 tg.add(run_enclave_and_gpu_tests, &enclaves[i]);
769 break;
770 default:
771 tg.add(run_enclave, &enclaves[i]);
772 break;
mtklein82d28432015-01-15 12:46:02 -0800773 }
mtklein55e88b22015-01-21 15:50:13 -0800774 }
mtklein748ca3b2015-01-15 10:56:12 -0800775 tg.wait();
mtklein748ca3b2015-01-15 10:56:12 -0800776 // At this point we're back in single-threaded land.
mtklein@google.comd36522d2013-10-16 13:02:15 +0000777
mtklein2f64eec2015-01-15 14:20:41 -0800778 SkDebugf("\n");
mtklein748ca3b2015-01-15 10:56:12 -0800779 if (gFailures.count() > 0) {
780 SkDebugf("Failures:\n");
781 for (int i = 0; i < gFailures.count(); i++) {
mtklein9dc09102015-01-15 15:47:33 -0800782 SkDebugf("\t%s\n", gFailures[i].c_str());
mtklein748ca3b2015-01-15 10:56:12 -0800783 }
784 SkDebugf("%d failures\n", gFailures.count());
785 return 1;
mtklein114c3cd2015-01-15 10:15:02 -0800786 }
mtklein748ca3b2015-01-15 10:56:12 -0800787 if (gPending > 0) {
788 SkDebugf("Hrm, we didn't seem to run everything we intended to! Please file a bug.\n");
789 return 1;
mtklein114c3cd2015-01-15 10:15:02 -0800790 }
mtklein748ca3b2015-01-15 10:56:12 -0800791 return 0;
mtklein@google.comd36522d2013-10-16 13:02:15 +0000792}
jcgregorio3b27ade2014-11-13 08:06:40 -0800793
borenet48087572015-04-02 12:16:36 -0700794#if !defined(SK_BUILD_FOR_IOS)
jcgregorio3b27ade2014-11-13 08:06:40 -0800795int main(int argc, char** argv) {
796 SkCommandLineFlags::Parse(argc, argv);
797 return dm_main();
798}
799#endif