blob: 57078fa4260bc9b7e99d733272410a8e90e10deb [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
mtkleine356c7f2014-10-06 11:24:08 -070051DEFINE_int32(threads, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
52 "defaulting to one extra thread per core.");
caryclark17f0b6d2014-07-22 10:15:34 -070053
54DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
55
56DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
mtkleinb5110422014-08-07 15:20:02 -070057
58DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
mtkleinea65bfa2014-09-09 07:59:46 -070059
60DEFINE_string(key, "",
61 "Space-separated key/value pairs to add to JSON identifying this builder.");
62DEFINE_string(properties, "",
63 "Space-separated key/value pairs to add to JSON identifying this run.");
benjaminwagner8d61f0d2016-01-25 13:02:40 -080064DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
scroggo86737142016-02-03 12:19:11 -080065
msarett69deca82016-04-29 09:38:40 -070066bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
scroggo86737142016-02-03 12:19:11 -080067 SkASSERT(output);
68
69 static const char* const exts[] = {
70 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
71 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
72#ifdef SK_CODEC_DECODES_RAW
73 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
74 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
75#endif
76 };
77
msarett69deca82016-04-29 09:38:40 -070078 for (int i = 0; i < images.count(); ++i) {
79 const char* flag = images[i];
scroggo86737142016-02-03 12:19:11 -080080 if (!sk_exists(flag)) {
81 SkDebugf("%s does not exist!\n", flag);
82 return false;
83 }
84
85 if (sk_isdir(flag)) {
86 // If the value passed in is a directory, add all the images
87 bool foundAnImage = false;
88 for (const char* ext : exts) {
89 SkOSFile::Iter it(flag, ext);
90 SkString file;
91 while (it.next(&file)) {
92 foundAnImage = true;
93 output->push_back() = SkOSPath::Join(flag, file.c_str());
94 }
95 }
96 if (!foundAnImage) {
97 SkDebugf("No supported images found in %s!\n", flag);
98 return false;
99 }
100 } else {
101 // Also add the value if it is a single image
102 output->push_back() = flag;
103 }
104 }
105 return true;
106}