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

Side by Side Diff: tests/skia_test.cpp

Issue 148173010: Revert of Add --skip_cpu and --skip_gpu options to tests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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 | « tests/Test.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "OverwriteLine.h" 8 #include "OverwriteLine.h"
9 #include "SkCommandLineFlags.h" 9 #include "SkCommandLineFlags.h"
10 #include "SkGraphics.h" 10 #include "SkGraphics.h"
(...skipping 17 matching lines...) Expand all
28 "$ requires the end of the test to match\n" \ 28 "$ requires the end of the test to match\n" \
29 "^ and $ requires an exact match\n" \ 29 "^ and $ requires an exact match\n" \
30 "If a test does not match any list entry,\n" \ 30 "If a test does not match any list entry,\n" \
31 "it is skipped unless some list entry starts with ~"); 31 "it is skipped unless some list entry starts with ~");
32 DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use."); 32 DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use.");
33 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); 33 DEFINE_string2(resourcePath, i, "resources", "directory for test resources.");
34 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); 34 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps.");
35 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); 35 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects.");
36 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); 36 DEFINE_bool2(single, z, false, "run tests on a single thread internally.");
37 DEFINE_bool2(verbose, v, false, "enable verbose output."); 37 DEFINE_bool2(verbose, v, false, "enable verbose output.");
38 DEFINE_bool(cpu, true, "whether or not to run CPU tests.");
39 DEFINE_bool(gpu, true, "whether or not to run GPU tests.");
40 DEFINE_int32(threads, SkThreadPool::kThreadPerCore, 38 DEFINE_int32(threads, SkThreadPool::kThreadPerCore,
41 "Run threadsafe tests on a threadpool with this many threads."); 39 "Run threadsafe tests on a threadpool with this many threads.");
42 40
43 // need to explicitly declare this, or we get some weird infinite loop llist 41 // need to explicitly declare this, or we get some weird infinite loop llist
44 template TestRegistry* TestRegistry::gHead; 42 template TestRegistry* TestRegistry::gHead;
45 43
46 class Iter { 44 class Iter {
47 public: 45 public:
48 Iter() { this->reset(); } 46 Iter() { this->reset(); }
49 void reset() { fReg = TestRegistry::Head(); } 47 void reset() { fReg = TestRegistry::Head(); }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 sk_atomic_inc(fFailCount); 117 sk_atomic_inc(fFailCount);
120 } 118 }
121 SkDELETE(this); 119 SkDELETE(this);
122 } 120 }
123 121
124 private: 122 private:
125 SkAutoTDelete<Test> fTest; 123 SkAutoTDelete<Test> fTest;
126 int32_t* fFailCount; 124 int32_t* fFailCount;
127 }; 125 };
128 126
129 static bool should_run(const char* testName, bool isGPUTest) {
130 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, testName)) {
131 return false;
132 }
133 if (!FLAGS_cpu && !isGPUTest) {
134 return false;
135 }
136 if (!FLAGS_gpu && isGPUTest) {
137 return false;
138 }
139 return true;
140 }
141
142 int tool_main(int argc, char** argv); 127 int tool_main(int argc, char** argv);
143 int tool_main(int argc, char** argv) { 128 int tool_main(int argc, char** argv) {
144 SkCommandLineFlags::SetUsage(""); 129 SkCommandLineFlags::SetUsage("");
145 SkCommandLineFlags::Parse(argc, argv); 130 SkCommandLineFlags::Parse(argc, argv);
146 131
147 #if SK_ENABLE_INST_COUNT 132 #if SK_ENABLE_INST_COUNT
148 if (FLAGS_leaks) { 133 if (FLAGS_leaks) {
149 gPrintInstCount = true; 134 gPrintInstCount = true;
150 } 135 }
151 #endif 136 #endif
(...skipping 27 matching lines...) Expand all
179 164
180 165
181 // Count tests first. 166 // Count tests first.
182 int total = 0; 167 int total = 0;
183 int toRun = 0; 168 int toRun = 0;
184 Test* test; 169 Test* test;
185 170
186 Iter iter; 171 Iter iter;
187 while ((test = iter.next(NULL/*reporter not needed*/)) != NULL) { 172 while ((test = iter.next(NULL/*reporter not needed*/)) != NULL) {
188 SkAutoTDelete<Test> owned(test); 173 SkAutoTDelete<Test> owned(test);
189 if (should_run(test->getName(), test->isGPUTest())) { 174
175 if(!SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) {
190 toRun++; 176 toRun++;
191 } 177 }
192 total++; 178 total++;
193 } 179 }
194 180
195 // Now run them. 181 // Now run them.
196 iter.reset(); 182 iter.reset();
197 int32_t failCount = 0; 183 int32_t failCount = 0;
198 int skipCount = 0; 184 int skipCount = 0;
199 185
200 SkThreadPool threadpool(FLAGS_threads); 186 SkThreadPool threadpool(FLAGS_threads);
201 SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnabl e 187 SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnabl e
202 188
203 DebugfReporter reporter(toRun); 189 DebugfReporter reporter(toRun);
204 for (int i = 0; i < total; i++) { 190 for (int i = 0; i < total; i++) {
205 SkAutoTDelete<Test> test(iter.next(&reporter)); 191 SkAutoTDelete<Test> test(iter.next(&reporter));
206 if (!should_run(test->getName(), test->isGPUTest())) { 192 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) {
207 ++skipCount; 193 ++skipCount;
208 } else if (!test->isGPUTest()) { 194 } else if (!test->isThreadsafe()) {
209 unsafeTests.push_back() = test.detach(); 195 unsafeTests.push_back() = test.detach();
210 } else { 196 } else {
211 threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount ))); 197 threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount )));
212 } 198 }
213 } 199 }
214 200
215 // Run the tests that aren't threadsafe. 201 // Run the tests that aren't threadsafe.
216 for (int i = 0; i < unsafeTests.count(); i++) { 202 for (int i = 0; i < unsafeTests.count(); i++) {
217 SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run(); 203 SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run();
218 } 204 }
(...skipping 10 matching lines...) Expand all
229 215
230 SkDebugf("\n"); 216 SkDebugf("\n");
231 return (failCount == 0) ? 0 : 1; 217 return (failCount == 0) ? 0 : 1;
232 } 218 }
233 219
234 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 220 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
235 int main(int argc, char * const argv[]) { 221 int main(int argc, char * const argv[]) {
236 return tool_main(argc, (char**) argv); 222 return tool_main(argc, (char**) argv);
237 } 223 }
238 #endif 224 #endif
OLDNEW
« no previous file with comments | « tests/Test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698