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

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: Remove isThreadsafe() 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.");
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 sk_atomic_inc(fFailCount); 119 sk_atomic_inc(fFailCount);
118 } 120 }
119 SkDELETE(this); 121 SkDELETE(this);
120 } 122 }
121 123
122 private: 124 private:
123 SkAutoTDelete<Test> fTest; 125 SkAutoTDelete<Test> fTest;
124 int32_t* fFailCount; 126 int32_t* fFailCount;
125 }; 127 };
126 128
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
127 int tool_main(int argc, char** argv); 142 int tool_main(int argc, char** argv);
128 int tool_main(int argc, char** argv) { 143 int tool_main(int argc, char** argv) {
129 SkCommandLineFlags::SetUsage(""); 144 SkCommandLineFlags::SetUsage("");
130 SkCommandLineFlags::Parse(argc, argv); 145 SkCommandLineFlags::Parse(argc, argv);
131 146
132 #if SK_ENABLE_INST_COUNT 147 #if SK_ENABLE_INST_COUNT
133 if (FLAGS_leaks) { 148 if (FLAGS_leaks) {
134 gPrintInstCount = true; 149 gPrintInstCount = true;
135 } 150 }
136 #endif 151 #endif
(...skipping 27 matching lines...) Expand all
164 179
165 180
166 // Count tests first. 181 // Count tests first.
167 int total = 0; 182 int total = 0;
168 int toRun = 0; 183 int toRun = 0;
169 Test* test; 184 Test* test;
170 185
171 Iter iter; 186 Iter iter;
172 while ((test = iter.next(NULL/*reporter not needed*/)) != NULL) { 187 while ((test = iter.next(NULL/*reporter not needed*/)) != NULL) {
173 SkAutoTDelete<Test> owned(test); 188 SkAutoTDelete<Test> owned(test);
174 189 if (should_run(test->getName(), test->isGPUTest())) {
175 if(!SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) {
176 toRun++; 190 toRun++;
177 } 191 }
178 total++; 192 total++;
179 } 193 }
180 194
181 // Now run them. 195 // Now run them.
182 iter.reset(); 196 iter.reset();
183 int32_t failCount = 0; 197 int32_t failCount = 0;
184 int skipCount = 0; 198 int skipCount = 0;
185 199
186 SkThreadPool threadpool(FLAGS_threads); 200 SkThreadPool threadpool(FLAGS_threads);
187 SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnabl e 201 SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnabl e
188 202
189 DebugfReporter reporter(toRun); 203 DebugfReporter reporter(toRun);
190 for (int i = 0; i < total; i++) { 204 for (int i = 0; i < total; i++) {
191 SkAutoTDelete<Test> test(iter.next(&reporter)); 205 SkAutoTDelete<Test> test(iter.next(&reporter));
192 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { 206 if (!should_run(test->getName(), test->isGPUTest())) {
193 ++skipCount; 207 ++skipCount;
194 } else if (!test->isThreadsafe()) { 208 } else if (!test->isGPUTest()) {
195 unsafeTests.push_back() = test.detach(); 209 unsafeTests.push_back() = test.detach();
196 } else { 210 } else {
197 threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount ))); 211 threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount )));
198 } 212 }
199 } 213 }
200 214
201 // Run the tests that aren't threadsafe. 215 // Run the tests that aren't threadsafe.
202 for (int i = 0; i < unsafeTests.count(); i++) { 216 for (int i = 0; i < unsafeTests.count(); i++) {
203 SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run(); 217 SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run();
204 } 218 }
(...skipping 10 matching lines...) Expand all
215 229
216 SkDebugf("\n"); 230 SkDebugf("\n");
217 return (failCount == 0) ? 0 : 1; 231 return (failCount == 0) ? 0 : 1;
218 } 232 }
219 233
220 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 234 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
221 int main(int argc, char * const argv[]) { 235 int main(int argc, char * const argv[]) {
222 return tool_main(argc, (char**) argv); 236 return tool_main(argc, (char**) argv);
223 } 237 }
224 #endif 238 #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