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