blob: a0aa94bdc08a65503288ca8b2d6aeea3f47e034d [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
Mike Klein08c89632016-11-08 14:16:01 -050053DEFINE_int32_2(threads, j, -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
liyuqian38911a72016-10-04 11:23:22 -070068DEFINE_bool(analyticAA, false, "Analytic Anati-Alias");
69
msarett69deca82016-04-29 09:38:40 -070070bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
scroggo86737142016-02-03 12:19:11 -080071 SkASSERT(output);
72
73 static const char* const exts[] = {
74 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
75 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
76#ifdef SK_CODEC_DECODES_RAW
77 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
78 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
79#endif
80 };
81
msarett69deca82016-04-29 09:38:40 -070082 for (int i = 0; i < images.count(); ++i) {
83 const char* flag = images[i];
scroggo86737142016-02-03 12:19:11 -080084 if (!sk_exists(flag)) {
85 SkDebugf("%s does not exist!\n", flag);
86 return false;
87 }
88
89 if (sk_isdir(flag)) {
90 // If the value passed in is a directory, add all the images
91 bool foundAnImage = false;
92 for (const char* ext : exts) {
93 SkOSFile::Iter it(flag, ext);
94 SkString file;
95 while (it.next(&file)) {
96 foundAnImage = true;
97 output->push_back() = SkOSPath::Join(flag, file.c_str());
98 }
99 }
100 if (!foundAnImage) {
101 SkDebugf("No supported images found in %s!\n", flag);
102 return false;
103 }
104 } else {
105 // Also add the value if it is a single image
106 output->push_back() = flag;
107 }
108 }
109 return true;
110}