| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <gflags/gflags.h> | 5 #include <gflags/gflags.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 | 11 |
| 12 #include "main.h" | 12 #include "main.h" |
| 13 #include "utils.h" | 13 #include "utils.h" |
| 14 | 14 |
| 15 #include "all_tests.h" | 15 #include "all_tests.h" |
| 16 #include "testbase.h" | 16 #include "testbase.h" |
| 17 | 17 |
| 18 using std::string; | 18 using std::string; |
| 19 using std::vector; | 19 using std::vector; |
| 20 | 20 |
| 21 DEFINE_int32(duration, 0, "run tests in a loop for at least this many seconds"); | 21 DEFINE_int32(duration, 0, "run tests in a loop for at least this many seconds"); |
| 22 DEFINE_string(tests, "", "colon-separated list of tests to run; " | 22 DEFINE_string(tests, "", "colon-separated list of tests to run; " |
| 23 "all tests if omitted"); | 23 "all tests if omitted"); |
| 24 DEFINE_bool(get_board_id, false, "return the board id for checksums"); | |
| 25 | 24 |
| 26 | 25 |
| 27 bool test_is_enabled(glbench::TestBase* test, | 26 bool test_is_enabled(glbench::TestBase* test, |
| 28 const vector<string>& enabled_tests) { | 27 const vector<string>& enabled_tests) { |
| 29 if (enabled_tests.empty()) | 28 if (enabled_tests.empty()) |
| 30 return true; | 29 return true; |
| 31 | 30 |
| 32 const char* test_name = test->Name(); | 31 const char* test_name = test->Name(); |
| 33 for (vector<string>::const_iterator i = enabled_tests.begin(); | 32 for (vector<string>::const_iterator i = enabled_tests.begin(); |
| 34 i != enabled_tests.end(); ++i) { | 33 i != enabled_tests.end(); ++i) { |
| 35 // This is not very precise, but will do until there's a need for something | 34 // This is not very precise, but will do until there's a need for something |
| 36 // more flexible. | 35 // more flexible. |
| 37 if (strstr(test_name, i->c_str())) | 36 if (strstr(test_name, i->c_str())) |
| 38 return true; | 37 return true; |
| 39 } | 38 } |
| 40 | 39 |
| 41 return false; | 40 return false; |
| 42 } | 41 } |
| 43 | 42 |
| 44 int main(int argc, char *argv[]) { | 43 int main(int argc, char *argv[]) { |
| 45 SetBasePathFromArgv0(argv[0], "src"); | 44 SetBasePathFromArgv0(argv[0], "src"); |
| 46 google::ParseCommandLineFlags(&argc, &argv, true); | 45 google::ParseCommandLineFlags(&argc, &argv, true); |
| 47 if (!Init()) { | 46 if (!Init()) { |
| 48 printf("# Failed to initialize.\n"); | 47 printf("# Failed to initialize.\n"); |
| 49 return 1; | 48 return 1; |
| 50 } | 49 } |
| 51 | 50 |
| 52 if (FLAGS_get_board_id) { | 51 InitContext(); |
| 53 InitContext(); | 52 printf("# board_id: %s / %s\n", |
| 54 printf("%s / %s\n", glGetString(GL_VENDOR), glGetString(GL_RENDERER)); | 53 glGetString(GL_VENDOR), glGetString(GL_RENDERER)); |
| 55 DestroyContext(); | 54 DestroyContext(); |
| 56 return 0; | |
| 57 } | |
| 58 | 55 |
| 59 vector<string> enabled_tests; | 56 vector<string> enabled_tests; |
| 60 SplitString(FLAGS_tests, ':', &enabled_tests); | 57 SplitString(FLAGS_tests, ':', &enabled_tests); |
| 61 | 58 |
| 62 glbench::TestBase* tests[] = { | 59 glbench::TestBase* tests[] = { |
| 63 glbench::GetSwapTest(), | 60 glbench::GetSwapTest(), |
| 64 glbench::GetClearTest(), | 61 glbench::GetClearTest(), |
| 65 glbench::GetFillRateTest(), | 62 glbench::GetFillRateTest(), |
| 66 #if defined(USE_OPENGL) | 63 #if defined(USE_OPENGL) |
| 67 glbench::GetWindowManagerCompositingTest(false), | 64 glbench::GetWindowManagerCompositingTest(false), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 86 } | 83 } |
| 87 } while (GetUTime() < done); | 84 } while (GetUTime() < done); |
| 88 | 85 |
| 89 for (unsigned int i = 0; i < arraysize(tests); i++) { | 86 for (unsigned int i = 0; i < arraysize(tests); i++) { |
| 90 delete tests[i]; | 87 delete tests[i]; |
| 91 tests[i] = NULL; | 88 tests[i] = NULL; |
| 92 } | 89 } |
| 93 | 90 |
| 94 return 0; | 91 return 0; |
| 95 } | 92 } |
| OLD | NEW |