caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 1 | /* |
| 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" |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 9 | #include "SkOSFile.h" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 10 | |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 11 | DEFINE_bool(cpu, true, "master switch for running CPU-bound work."); |
| 12 | |
| 13 | DEFINE_bool(dryRun, false, |
| 14 | "just print the tests that would be run, without actually running them."); |
| 15 | |
| 16 | DEFINE_bool(gpu, true, "master switch for running GPU-bound work."); |
| 17 | |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 18 | DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images" |
| 19 | " is treated as a fatal error."); |
msarett | 95f192d | 2015-02-13 09:05:41 -0800 | [diff] [blame] | 20 | |
msarett | 69deca8 | 2016-04-29 09:38:40 -0700 | [diff] [blame] | 21 | DEFINE_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 | |
msarett | db197a5 | 2016-06-21 09:44:29 -0700 | [diff] [blame] | 24 | DEFINE_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 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 29 | DEFINE_string2(match, m, nullptr, |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 30 | "[~][^]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 | |
| 39 | DEFINE_bool2(quiet, q, false, "if true, don't print status updates."); |
| 40 | |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 41 | DEFINE_bool(preAbandonGpuContext, false, "Test abandoning the GrContext before running the test."); |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 42 | |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 43 | DEFINE_bool(abandonGpuContext, false, "Test abandoning the GrContext after running each test."); |
| 44 | |
| 45 | DEFINE_bool(releaseAndAbandonGpuContext, false, |
| 46 | "Test releasing all gpu resources and abandoning the GrContext after running each " |
| 47 | "test"); |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 48 | |
mtklein | 34580f7 | 2014-08-07 12:46:29 -0700 | [diff] [blame] | 49 | DEFINE_string(skps, "skps", "Directory to read skps from."); |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 50 | |
fmalita | 95573e4 | 2016-09-14 09:05:43 -0700 | [diff] [blame^] | 51 | DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file."); |
| 52 | |
mtklein | e356c7f | 2014-10-06 11:24:08 -0700 | [diff] [blame] | 53 | DEFINE_int32(threads, -1, "Run threadsafe tests on a threadpool with this many extra threads, " |
| 54 | "defaulting to one extra thread per core."); |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 55 | |
| 56 | DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); |
| 57 | |
| 58 | DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); |
mtklein | b511042 | 2014-08-07 15:20:02 -0700 | [diff] [blame] | 59 | |
| 60 | DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs."); |
mtklein | ea65bfa | 2014-09-09 07:59:46 -0700 | [diff] [blame] | 61 | |
| 62 | DEFINE_string(key, "", |
| 63 | "Space-separated key/value pairs to add to JSON identifying this builder."); |
| 64 | DEFINE_string(properties, "", |
| 65 | "Space-separated key/value pairs to add to JSON identifying this run."); |
benjaminwagner | 8d61f0d | 2016-01-25 13:02:40 -0800 | [diff] [blame] | 66 | DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading"); |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 67 | |
msarett | 69deca8 | 2016-04-29 09:38:40 -0700 | [diff] [blame] | 68 | bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) { |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 69 | SkASSERT(output); |
| 70 | |
| 71 | static const char* const exts[] = { |
| 72 | "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico", |
| 73 | "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO", |
| 74 | #ifdef SK_CODEC_DECODES_RAW |
| 75 | "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw", |
| 76 | "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW", |
| 77 | #endif |
| 78 | }; |
| 79 | |
msarett | 69deca8 | 2016-04-29 09:38:40 -0700 | [diff] [blame] | 80 | for (int i = 0; i < images.count(); ++i) { |
| 81 | const char* flag = images[i]; |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 82 | if (!sk_exists(flag)) { |
| 83 | SkDebugf("%s does not exist!\n", flag); |
| 84 | return false; |
| 85 | } |
| 86 | |
| 87 | if (sk_isdir(flag)) { |
| 88 | // If the value passed in is a directory, add all the images |
| 89 | bool foundAnImage = false; |
| 90 | for (const char* ext : exts) { |
| 91 | SkOSFile::Iter it(flag, ext); |
| 92 | SkString file; |
| 93 | while (it.next(&file)) { |
| 94 | foundAnImage = true; |
| 95 | output->push_back() = SkOSPath::Join(flag, file.c_str()); |
| 96 | } |
| 97 | } |
| 98 | if (!foundAnImage) { |
| 99 | SkDebugf("No supported images found in %s!\n", flag); |
| 100 | return false; |
| 101 | } |
| 102 | } else { |
| 103 | // Also add the value if it is a single image |
| 104 | output->push_back() = flag; |
| 105 | } |
| 106 | } |
| 107 | return true; |
| 108 | } |