blob: bf2bde0426d929de8f56cac90a3a4664f5bdd030 [file] [log] [blame]
caryclark17f0b6d2014-07-22 10:15:34 -07001/*
2 * Copyright 2014 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
8#include "SkCommonFlags.h"
scroggo86737142016-02-03 12:19:11 -08009#include "SkOSFile.h"
caryclark17f0b6d2014-07-22 10:15:34 -070010
caryclark17f0b6d2014-07-22 10:15:34 -070011DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
12
13DEFINE_bool(dryRun, false,
14 "just print the tests that would be run, without actually running them.");
15
16DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
17
scroggo86737142016-02-03 12:19:11 -080018DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images"
19 " is treated as a fatal error.");
msarett95f192d2015-02-13 09:05:41 -080020
msarett69deca82016-04-29 09:38:40 -070021DEFINE_string(colorImages, "", "List of images and/or directories to decode with color correction. "
22 "A directory with no images is treated as a fatal error.");
23
msarettdb197a52016-06-21 09:44:29 -070024DEFINE_bool(simpleCodec, false, "Runs of a subset of the codec tests. "
25 "For DM, this means no scaling or subsetting, always using the "
26 "canvas color type. "
27 "For nanobench, this means always N32, Premul or Opaque.");
28
halcanary96fcdcc2015-08-27 07:41:13 -070029DEFINE_string2(match, m, nullptr,
caryclark17f0b6d2014-07-22 10:15:34 -070030 "[~][^]substring[$] [...] of GM name to run.\n"
31 "Multiple matches may be separated by spaces.\n"
32 "~ causes a matching GM to always be skipped\n"
33 "^ requires the start of the GM to match\n"
34 "$ requires the end of the GM to match\n"
35 "^ and $ requires an exact match\n"
36 "If a GM does not match any list entry,\n"
37 "it is skipped unless some list entry starts with ~");
38
39DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
40
bsalomon6e2aad42016-04-01 11:54:31 -070041DEFINE_bool(preAbandonGpuContext, false, "Test abandoning the GrContext before running the test.");
joshualitt5f5a8d72015-02-25 14:09:45 -080042
bsalomon6e2aad42016-04-01 11:54:31 -070043DEFINE_bool(abandonGpuContext, false, "Test abandoning the GrContext after running each test.");
44
45DEFINE_bool(releaseAndAbandonGpuContext, false,
46 "Test releasing all gpu resources and abandoning the GrContext after running each "
47 "test");
caryclark17f0b6d2014-07-22 10:15:34 -070048
mtklein34580f72014-08-07 12:46:29 -070049DEFINE_string(skps, "skps", "Directory to read skps from.");
mtklein92007582014-08-01 07:46:52 -070050
fmalita95573e42016-09-14 09:05:43 -070051DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
52
mtkleine356c7f2014-10-06 11:24:08 -070053DEFINE_int32(threads, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
54 "defaulting to one extra thread per core.");
caryclark17f0b6d2014-07-22 10:15:34 -070055
56DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
57
58DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
mtkleinb5110422014-08-07 15:20:02 -070059
60DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
mtkleinea65bfa2014-09-09 07:59:46 -070061
62DEFINE_string(key, "",
63 "Space-separated key/value pairs to add to JSON identifying this builder.");
64DEFINE_string(properties, "",
65 "Space-separated key/value pairs to add to JSON identifying this run.");
benjaminwagner8d61f0d2016-01-25 13:02:40 -080066DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
scroggo86737142016-02-03 12:19:11 -080067
msarett69deca82016-04-29 09:38:40 -070068bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
scroggo86737142016-02-03 12:19:11 -080069 SkASSERT(output);
70
71 static const char* const exts[] = {
72 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
73 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
74#ifdef SK_CODEC_DECODES_RAW
75 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
76 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
77#endif
78 };
79
msarett69deca82016-04-29 09:38:40 -070080 for (int i = 0; i < images.count(); ++i) {
81 const char* flag = images[i];
scroggo86737142016-02-03 12:19:11 -080082 if (!sk_exists(flag)) {
83 SkDebugf("%s does not exist!\n", flag);
84 return false;
85 }
86
87 if (sk_isdir(flag)) {
88 // If the value passed in is a directory, add all the images
89 bool foundAnImage = false;
90 for (const char* ext : exts) {
91 SkOSFile::Iter it(flag, ext);
92 SkString file;
93 while (it.next(&file)) {
94 foundAnImage = true;
95 output->push_back() = SkOSPath::Join(flag, file.c_str());
96 }
97 }
98 if (!foundAnImage) {
99 SkDebugf("No supported images found in %s!\n", flag);
100 return false;
101 }
102 } else {
103 // Also add the value if it is a single image
104 output->push_back() = flag;
105 }
106 }
107 return true;
108}