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

Side by Side Diff: tests/skia_test.cpp

Issue 144343004: 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
« tests/Test.h ('K') | « 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(skip_cpu, false, "skip CPU tests.");
mtklein 2014/01/27 22:35:29 Would somewhat prefer to keep the flags positively
djsollen 2014/01/28 14:21:02 I'm a fan of this as well. On 2014/01/27 22:35:29
borenet 2014/01/28 18:42:09 Done.
39 DEFINE_bool(skip_gpu, false, "skip GPU tests.");
38 DEFINE_int32(threads, SkThreadPool::kThreadPerCore, 40 DEFINE_int32(threads, SkThreadPool::kThreadPerCore,
39 "Run threadsafe tests on a threadpool with this many threads."); 41 "Run threadsafe tests on a threadpool with this many threads.");
40 42
41 // need to explicitly declare this, or we get some weird infinite loop llist 43 // need to explicitly declare this, or we get some weird infinite loop llist
42 template TestRegistry* TestRegistry::gHead; 44 template TestRegistry* TestRegistry::gHead;
43 45
44 class Iter { 46 class Iter {
45 public: 47 public:
46 Iter() { this->reset(); } 48 Iter() { this->reset(); }
47 void reset() { fReg = TestRegistry::Head(); } 49 void reset() { fReg = TestRegistry::Head(); }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 int total = 0; 169 int total = 0;
168 int toRun = 0; 170 int toRun = 0;
169 Test* test; 171 Test* test;
170 172
171 Iter iter; 173 Iter iter;
172 while ((test = iter.next(NULL/*reporter not needed*/)) != NULL) { 174 while ((test = iter.next(NULL/*reporter not needed*/)) != NULL) {
173 SkAutoTDelete<Test> owned(test); 175 SkAutoTDelete<Test> owned(test);
174 176
175 if(!SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { 177 if(!SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) {
176 toRun++; 178 toRun++;
179 } else if (test->isGPUTest() && !FLAGS_skip_gpu){
mtklein 2014/01/27 22:35:29 I think this is going to double-count? Shouldn't
borenet 2014/01/28 18:42:09 Moved to its own function for clarity.
180 toRun++;
181 } else if (!test->isGPUTest() && !FLAGS_skip_cpu) {
182 toRun++;
177 } 183 }
178 total++; 184 total++;
179 } 185 }
180 186
181 // Now run them. 187 // Now run them.
182 iter.reset(); 188 iter.reset();
183 int32_t failCount = 0; 189 int32_t failCount = 0;
184 int skipCount = 0; 190 int skipCount = 0;
185 191
186 SkThreadPool threadpool(FLAGS_threads); 192 SkThreadPool threadpool(FLAGS_threads);
187 SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnabl e 193 SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnabl e
188 194
189 DebugfReporter reporter(toRun); 195 DebugfReporter reporter(toRun);
190 for (int i = 0; i < total; i++) { 196 for (int i = 0; i < total; i++) {
191 SkAutoTDelete<Test> test(iter.next(&reporter)); 197 SkAutoTDelete<Test> test(iter.next(&reporter));
192 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { 198 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) {
193 ++skipCount; 199 ++skipCount;
200 } else if (test->isGPUTest() && FLAGS_skip_gpu) {
mtklein 2014/01/27 22:35:29 Same deal down here.
201 ++skipCount;
202 } else if (!test->isGPUTest() && FLAGS_skip_cpu) {
203 ++skipCount;
194 } else if (!test->isThreadsafe()) { 204 } else if (!test->isThreadsafe()) {
195 unsafeTests.push_back() = test.detach(); 205 unsafeTests.push_back() = test.detach();
196 } else { 206 } else {
197 threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount ))); 207 threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount )));
198 } 208 }
199 } 209 }
200 210
201 // Run the tests that aren't threadsafe. 211 // Run the tests that aren't threadsafe.
202 for (int i = 0; i < unsafeTests.count(); i++) { 212 for (int i = 0; i < unsafeTests.count(); i++) {
203 SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run(); 213 SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run();
(...skipping 11 matching lines...) Expand all
215 225
216 SkDebugf("\n"); 226 SkDebugf("\n");
217 return (failCount == 0) ? 0 : 1; 227 return (failCount == 0) ? 0 : 1;
218 } 228 }
219 229
220 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 230 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
221 int main(int argc, char * const argv[]) { 231 int main(int argc, char * const argv[]) {
222 return tool_main(argc, (char**) argv); 232 return tool_main(argc, (char**) argv);
223 } 233 }
224 #endif 234 #endif
OLDNEW
« tests/Test.h ('K') | « tests/Test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698