Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: dm/DM.cpp

Issue 179403010: Revert of Let DM run unit tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | dm/DMGpuTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Main binary for DM. 1 // Main binary for DM.
2 // For a high-level overview, please see dm/README. 2 // For a high-level overview, please see dm/README.
3 3
4 #include "GrContext.h" 4 #include "GrContext.h"
5 #include "GrContextFactory.h" 5 #include "GrContextFactory.h"
6 #include "SkCommandLineFlags.h" 6 #include "SkCommandLineFlags.h"
7 #include "SkForceLinking.h" 7 #include "SkForceLinking.h"
8 #include "SkGraphics.h" 8 #include "SkGraphics.h"
9 #include "SkString.h" 9 #include "SkString.h"
10 #include "Test.h"
11 #include "gm.h" 10 #include "gm.h"
12 11
13 #include "DMCpuTask.h"
14 #include "DMGpuTask.h"
15 #include "DMReporter.h" 12 #include "DMReporter.h"
16 #include "DMTask.h" 13 #include "DMTask.h"
17 #include "DMTaskRunner.h" 14 #include "DMTaskRunner.h"
18 #include "DMTestTask.h" 15 #include "DMCpuTask.h"
16 #include "DMGpuTask.h"
19 #include "DMWriteTask.h" 17 #include "DMWriteTask.h"
20 18
21 #include <string.h> 19 #include <string.h>
22 20
23 using skiagm::GM; 21 using skiagm::GM;
24 using skiagm::GMRegistry; 22 using skiagm::GMRegistry;
25 using skiatest::Test;
26 using skiatest::TestRegistry;
27 23
28 DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS."); 24 DEFINE_int32(cpuThreads, -1, "Threads for CPU work. Default NUM_CPUS.");
25 DEFINE_int32(gpuThreads, 1, "Threads for GPU work.");
29 DEFINE_string2(expectations, r, "", 26 DEFINE_string2(expectations, r, "",
30 "If a directory, compare generated images against images under th is path. " 27 "If a directory, compare generated images against images under th is path. "
31 "If a file, compare generated images against JSON expectations at this path."); 28 "If a file, compare generated images against JSON expectations at this path.");
32 DEFINE_string2(resources, i, "resources", "Path to resources directory."); 29 DEFINE_string(resources, "resources", "Path to resources directory.");
33 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n" 30 DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n"
34 "Multiple matches may be separated by spaces.\n" 31 "Multiple matches may be separated by spaces.\n"
35 "~ causes a matching GM to always be skipped\n" 32 "~ causes a matching GM to always be skipped\n"
36 "^ requires the start of the GM to match\n" 33 "^ requires the start of the GM to match\n"
37 "$ requires the end of the GM to match\n" 34 "$ requires the end of the GM to match\n"
38 "^ and $ requires an exact match\n" 35 "^ and $ requires an exact match\n"
39 "If a GM does not match any list entry,\n" 36 "If a GM does not match any list entry,\n"
40 "it is skipped unless some list entry starts with ~"); 37 "it is skipped unless some list entry starts with ~");
41 DEFINE_string(config, "565 8888 gpu", 38 DEFINE_string(config, "565 8888 gpu",
42 "Options: 565 8888 gpu msaa4 msaa16 gpunull gpudebug angle mesa"); // TO DO(mtklein): pdf 39 "Options: 565 8888 gpu msaa4 msaa16 gpunull gpudebug angle mesa"); // TO DO(mtklein): pdf
43 DEFINE_bool(leaks, false, "Print leaked instance-counted objects at exit?");
44
45 DEFINE_bool(gms, true, "Run GMs?");
46 DEFINE_bool(tests, true, "Run tests?");
47 40
48 __SK_FORCE_IMAGE_DECODER_LINKING; 41 __SK_FORCE_IMAGE_DECODER_LINKING;
49 42
50 // "FooBar" -> "foobar". Obviously, ASCII only. 43 // "FooBar" -> "foobar". Obviously, ASCII only.
51 static SkString lowercase(SkString s) { 44 static SkString lowercase(SkString s) {
52 for (size_t i = 0; i < s.size(); i++) { 45 for (size_t i = 0; i < s.size(); i++) {
53 s[i] = tolower(s[i]); 46 s[i] = tolower(s[i]);
54 } 47 }
55 return s; 48 return s;
56 } 49 }
57 50
58 static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms, 51 static void kick_off_tasks(const SkTDArray<GMRegistry::Factory>& gms,
59 const SkTArray<SkString>& configs, 52 const SkTArray<SkString>& configs,
60 const DM::Expectations& expectations, 53 const DM::Expectations& expectations,
61 DM::Reporter* reporter, 54 DM::Reporter* reporter,
62 DM::TaskRunner* tasks) { 55 DM::TaskRunner* tasks) {
63 const SkColorType _565 = kRGB_565_SkColorType; 56 const SkColorType _565 = kRGB_565_SkColorType;
64 const SkColorType _8888 = kPMColor_SkColorType; 57 const SkColorType _8888 = kPMColor_SkColorType;
65 const GrContextFactory::GLContextType native = GrContextFactory::kNative_GLC ontextType; 58 const GrContextFactory::GLContextType native = GrContextFactory::kNative_GLC ontextType;
66 const GrContextFactory::GLContextType null = GrContextFactory::kNull_GLCon textType; 59 const GrContextFactory::GLContextType null = GrContextFactory::kNull_GLCon textType;
67 const GrContextFactory::GLContextType debug = GrContextFactory::kDebug_GLCo ntextType; 60 const GrContextFactory::GLContextType debug = GrContextFactory::kDebug_GLCo ntextType;
68 const GrContextFactory::GLContextType angle = 61 const GrContextFactory::GLContextType angle =
69 #if SK_ANGLE 62 #if SK_ANGLE
70 GrContextFactory::kANGLE_GLContextType; 63 GrContextFactory::kANGLE_GLContextType;
71 #else 64 #else
72 native; 65 native;
(...skipping 20 matching lines...) Expand all
93 START("gpunull", GpuTask, _8888, null, 0); 86 START("gpunull", GpuTask, _8888, null, 0);
94 START("gpudebug", GpuTask, _8888, debug, 0); 87 START("gpudebug", GpuTask, _8888, debug, 0);
95 START("angle", GpuTask, _8888, angle, 0); 88 START("angle", GpuTask, _8888, angle, 0);
96 START("mesa", GpuTask, _8888, mesa, 0); 89 START("mesa", GpuTask, _8888, mesa, 0);
97 //START("pdf", PdfTask, _8888); 90 //START("pdf", PdfTask, _8888);
98 } 91 }
99 } 92 }
100 #undef START 93 #undef START
101 } 94 }
102 95
103 static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests,
104 DM::Reporter* reporter,
105 DM::TaskRunner* tasks) {
106 for (int i = 0; i < tests.count(); i++) {
107 tasks->add(SkNEW_ARGS(DM::TestTask, (reporter, tasks, tests[i])));
108 }
109 }
110
111 static void report_failures(const DM::Reporter& reporter) { 96 static void report_failures(const DM::Reporter& reporter) {
112 SkTArray<SkString> failures; 97 SkTArray<SkString> failures;
113 reporter.getFailures(&failures); 98 reporter.getFailures(&failures);
114 99
115 if (failures.count() == 0) { 100 if (failures.count() == 0) {
116 return; 101 return;
117 } 102 }
118 103
119 SkDebugf("Failures:\n"); 104 SkDebugf("Failures:\n");
120 for (int i = 0; i < failures.count(); i++) { 105 for (int i = 0; i < failures.count(); i++) {
121 SkDebugf(" %s\n", failures[i].c_str()); 106 SkDebugf(" %s\n", failures[i].c_str());
122 } 107 }
123 } 108 }
124 109
125 int tool_main(int argc, char** argv); 110 int tool_main(int argc, char** argv);
126 int tool_main(int argc, char** argv) { 111 int tool_main(int argc, char** argv) {
127 #if SK_ENABLE_INST_COUNT
128 gPrintInstCount = FLAGS_leaks;
129 #endif
130 SkGraphics::Init(); 112 SkGraphics::Init();
113
131 SkCommandLineFlags::Parse(argc, argv); 114 SkCommandLineFlags::Parse(argc, argv);
132 GM::SetResourcePath(FLAGS_resources[0]); 115 GM::SetResourcePath(FLAGS_resources[0]);
133 Test::SetResourcePath(FLAGS_resources[0]); 116 SkTArray<SkString> configs;
117 for (int i = 0; i < FLAGS_config.count(); i++) {
118 SkStrSplit(FLAGS_config[i], ", ", &configs);
119 }
134 120
135 SkTArray<SkString> configs;
136 SkTDArray<GMRegistry::Factory> gms; 121 SkTDArray<GMRegistry::Factory> gms;
122 for (const GMRegistry* reg = GMRegistry::Head(); reg != NULL; reg = reg->nex t()) {
123 SkAutoTDelete<GM> gmForName(reg->factory()(NULL));
124 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, gmForName->shortName()) ) {
125 *gms.append() = reg->factory();
126 }
127 }
128 SkDebugf("%d GMs x %d configs\n", gms.count(), configs.count());
129
137 SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations)); 130 SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations));
138 131 if (FLAGS_expectations.count() > 0) {
139 if (FLAGS_gms) { 132 const char* path = FLAGS_expectations[0];
140 for (int i = 0; i < FLAGS_config.count(); i++) { 133 if (sk_isdir(path)) {
141 SkStrSplit(FLAGS_config[i], ", ", &configs); 134 expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path)));
142 } 135 } else {
143 136 expectations.reset(SkNEW_ARGS(DM::JsonExpectations, (path)));
144 for (const GMRegistry* reg = GMRegistry::Head(); reg != NULL; reg = reg- >next()) {
145 SkAutoTDelete<GM> gmForName(reg->factory()(NULL));
146 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, gmForName->shortNam e())) {
147 *gms.append() = reg->factory();
148 }
149 }
150
151 if (FLAGS_expectations.count() > 0) {
152 const char* path = FLAGS_expectations[0];
153 if (sk_isdir(path)) {
154 expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path )));
155 } else {
156 expectations.reset(SkNEW_ARGS(DM::JsonExpectations, (path)));
157 }
158 } 137 }
159 } 138 }
160 139
161 SkTDArray<TestRegistry::Factory> tests;
162 if (FLAGS_tests) {
163 for (const TestRegistry* reg = TestRegistry::Head(); reg != NULL; reg = reg->next()) {
164 SkAutoTDelete<Test> testForName(reg->factory()(NULL));
165 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, testForName->getNam e())) {
166 *tests.append() = reg->factory();
167 }
168 }
169 }
170
171 SkDebugf("%d GMs x %d configs, %d tests\n", gms.count(), configs.count(), te sts.count());
172 DM::Reporter reporter; 140 DM::Reporter reporter;
173 DM::TaskRunner tasks(FLAGS_threads); 141 DM::TaskRunner tasks(FLAGS_cpuThreads, FLAGS_gpuThreads);
174 kick_off_gms(gms, configs, *expectations, &reporter, &tasks); 142 kick_off_tasks(gms, configs, *expectations, &reporter, &tasks);
175 kick_off_tests(tests, &reporter, &tasks);
176 tasks.wait(); 143 tasks.wait();
177 144
145 reporter.updateStatusLine();
178 SkDebugf("\n"); 146 SkDebugf("\n");
179 report_failures(reporter); 147 report_failures(reporter);
180 148
181 SkGraphics::Term(); 149 SkGraphics::Term();
182 150
183 return reporter.failed() > 0; 151 return reporter.failed() > 0;
184 } 152 }
185 153
186 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 154 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
187 int main(int argc, char** argv) { 155 int main(int argc, char** argv) {
188 return tool_main(argc, argv); 156 return tool_main(argc, argv);
189 } 157 }
190 #endif 158 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMGpuTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698