blob: 1caffd54d6a5b58bca2cd481a6a618c0d57c6bf2 [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
halcanary96fcdcc2015-08-27 07:41:13 -070024DEFINE_string2(match, m, nullptr,
caryclark17f0b6d2014-07-22 10:15:34 -070025 "[~][^]substring[$] [...] of GM name to run.\n"
26 "Multiple matches may be separated by spaces.\n"
27 "~ causes a matching GM to always be skipped\n"
28 "^ requires the start of the GM to match\n"
29 "$ requires the end of the GM to match\n"
30 "^ and $ requires an exact match\n"
31 "If a GM does not match any list entry,\n"
32 "it is skipped unless some list entry starts with ~");
33
34DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
35
bsalomon6e2aad42016-04-01 11:54:31 -070036DEFINE_bool(preAbandonGpuContext, false, "Test abandoning the GrContext before running the test.");
joshualitt5f5a8d72015-02-25 14:09:45 -080037
bsalomon6e2aad42016-04-01 11:54:31 -070038DEFINE_bool(abandonGpuContext, false, "Test abandoning the GrContext after running each test.");
39
40DEFINE_bool(releaseAndAbandonGpuContext, false,
41 "Test releasing all gpu resources and abandoning the GrContext after running each "
42 "test");
caryclark17f0b6d2014-07-22 10:15:34 -070043
mtklein34580f72014-08-07 12:46:29 -070044DEFINE_string(skps, "skps", "Directory to read skps from.");
mtklein92007582014-08-01 07:46:52 -070045
mtkleine356c7f2014-10-06 11:24:08 -070046DEFINE_int32(threads, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
47 "defaulting to one extra thread per core.");
caryclark17f0b6d2014-07-22 10:15:34 -070048
49DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
50
51DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
mtkleinb5110422014-08-07 15:20:02 -070052
53DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
mtkleinea65bfa2014-09-09 07:59:46 -070054
55DEFINE_string(key, "",
56 "Space-separated key/value pairs to add to JSON identifying this builder.");
57DEFINE_string(properties, "",
58 "Space-separated key/value pairs to add to JSON identifying this run.");
benjaminwagner8d61f0d2016-01-25 13:02:40 -080059DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading");
scroggo86737142016-02-03 12:19:11 -080060
msarett69deca82016-04-29 09:38:40 -070061bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) {
scroggo86737142016-02-03 12:19:11 -080062 SkASSERT(output);
63
64 static const char* const exts[] = {
65 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico",
66 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO",
67#ifdef SK_CODEC_DECODES_RAW
68 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
69 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
70#endif
71 };
72
msarett69deca82016-04-29 09:38:40 -070073 for (int i = 0; i < images.count(); ++i) {
74 const char* flag = images[i];
scroggo86737142016-02-03 12:19:11 -080075 if (!sk_exists(flag)) {
76 SkDebugf("%s does not exist!\n", flag);
77 return false;
78 }
79
80 if (sk_isdir(flag)) {
81 // If the value passed in is a directory, add all the images
82 bool foundAnImage = false;
83 for (const char* ext : exts) {
84 SkOSFile::Iter it(flag, ext);
85 SkString file;
86 while (it.next(&file)) {
87 foundAnImage = true;
88 output->push_back() = SkOSPath::Join(flag, file.c_str());
89 }
90 }
91 if (!foundAnImage) {
92 SkDebugf("No supported images found in %s!\n", flag);
93 return false;
94 }
95 } else {
96 // Also add the value if it is a single image
97 output->push_back() = flag;
98 }
99 }
100 return true;
101}