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 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 21 | DEFINE_string2(match, m, nullptr, |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 22 | "[~][^]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 | |
| 31 | DEFINE_bool2(quiet, q, false, "if true, don't print status updates."); |
| 32 | |
joshualitt | 5f5a8d7 | 2015-02-25 14:09:45 -0800 | [diff] [blame] | 33 | DEFINE_bool(preAbandonGpuContext, false, "Abandons the GrContext before running the test."); |
| 34 | |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 35 | DEFINE_bool(abandonGpuContext, false, "Abandon the GrContext after running each test."); |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 36 | |
mtklein | 34580f7 | 2014-08-07 12:46:29 -0700 | [diff] [blame] | 37 | DEFINE_string(skps, "skps", "Directory to read skps from."); |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 38 | |
mtklein | e356c7f | 2014-10-06 11:24:08 -0700 | [diff] [blame] | 39 | DEFINE_int32(threads, -1, "Run threadsafe tests on a threadpool with this many extra threads, " |
| 40 | "defaulting to one extra thread per core."); |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 41 | |
| 42 | DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); |
| 43 | |
| 44 | DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); |
mtklein | b511042 | 2014-08-07 15:20:02 -0700 | [diff] [blame] | 45 | |
| 46 | DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs."); |
mtklein | ea65bfa | 2014-09-09 07:59:46 -0700 | [diff] [blame] | 47 | |
| 48 | DEFINE_string(key, "", |
| 49 | "Space-separated key/value pairs to add to JSON identifying this builder."); |
| 50 | DEFINE_string(properties, "", |
| 51 | "Space-separated key/value pairs to add to JSON identifying this run."); |
benjaminwagner | 8d61f0d | 2016-01-25 13:02:40 -0800 | [diff] [blame] | 52 | 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^] | 53 | |
| 54 | bool CollectImages(SkTArray<SkString>* output) { |
| 55 | SkASSERT(output); |
| 56 | |
| 57 | static const char* const exts[] = { |
| 58 | "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico", |
| 59 | "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO", |
| 60 | #ifdef SK_CODEC_DECODES_RAW |
| 61 | "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw", |
| 62 | "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW", |
| 63 | #endif |
| 64 | }; |
| 65 | |
| 66 | for (int i = 0; i < FLAGS_images.count(); ++i) { |
| 67 | const char* flag = FLAGS_images[i]; |
| 68 | if (!sk_exists(flag)) { |
| 69 | SkDebugf("%s does not exist!\n", flag); |
| 70 | return false; |
| 71 | } |
| 72 | |
| 73 | if (sk_isdir(flag)) { |
| 74 | // If the value passed in is a directory, add all the images |
| 75 | bool foundAnImage = false; |
| 76 | for (const char* ext : exts) { |
| 77 | SkOSFile::Iter it(flag, ext); |
| 78 | SkString file; |
| 79 | while (it.next(&file)) { |
| 80 | foundAnImage = true; |
| 81 | output->push_back() = SkOSPath::Join(flag, file.c_str()); |
| 82 | } |
| 83 | } |
| 84 | if (!foundAnImage) { |
| 85 | SkDebugf("No supported images found in %s!\n", flag); |
| 86 | return false; |
| 87 | } |
| 88 | } else { |
| 89 | // Also add the value if it is a single image |
| 90 | output->push_back() = flag; |
| 91 | } |
| 92 | } |
| 93 | return true; |
| 94 | } |