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