Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
Alexey Marinichev | 6294a39 | 2010-03-02 16:53:36 -0800 | [diff] [blame] | 5 | #include <fcntl.h> |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 6 | #include <stdio.h> |
| 7 | #include <stdlib.h> |
Alexey Marinichev | 19b5a5d | 2010-02-18 11:37:26 -0800 | [diff] [blame] | 8 | #include <string.h> |
Alexey Marinichev | 6294a39 | 2010-03-02 16:53:36 -0800 | [diff] [blame] | 9 | #include <sys/mman.h> |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 10 | |
Alexey Marinichev | af0b26d | 2010-02-24 13:03:13 -0800 | [diff] [blame] | 11 | #include "base/logging.h" |
| 12 | |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 13 | #include "main.h" |
Alexey Marinichev | 3c19973 | 2010-03-11 10:33:35 -0800 | [diff] [blame] | 14 | #include "utils.h" |
Alexey Marinichev | 6294a39 | 2010-03-02 16:53:36 -0800 | [diff] [blame] | 15 | #include "yuv2rgb.h" |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 16 | |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame^] | 17 | #include "all_tests.h" |
| 18 | #include "testbase.h" |
| 19 | |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 20 | |
Darin Petkov | dd31496 | 2010-02-18 16:21:29 -0800 | [diff] [blame] | 21 | const int enabled_tests_max = 8; |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame^] | 22 | // TODO: fix enabled_tests. |
Alexey Marinichev | 19b5a5d | 2010-02-18 11:37:26 -0800 | [diff] [blame] | 23 | const char *enabled_tests[enabled_tests_max+1] = {NULL}; |
| 24 | int seconds_to_run = 0; |
| 25 | |
Alexey Marinichev | 0f9aa1b | 2010-03-30 14:38:16 -0700 | [diff] [blame] | 26 | |
Alexey Marinichev | 19b5a5d | 2010-02-18 11:37:26 -0800 | [diff] [blame] | 27 | // TODO: use proper command line parsing library. |
| 28 | static void ParseArgs(int argc, char *argv[]) { |
| 29 | const char **enabled_tests_ptr = enabled_tests; |
| 30 | bool test_name_arg = false; |
| 31 | bool duration_arg = false; |
| 32 | for (int i = 0; i < argc; i++) { |
| 33 | if (test_name_arg) { |
| 34 | test_name_arg = false; |
| 35 | *enabled_tests_ptr++ = argv[i]; |
| 36 | if (enabled_tests_ptr - enabled_tests >= enabled_tests_max) |
| 37 | break; |
| 38 | } else if (duration_arg) { |
| 39 | duration_arg = false; |
| 40 | seconds_to_run = atoi(argv[i]); |
| 41 | } else if (strcmp("-t", argv[i]) == 0) { |
| 42 | test_name_arg = true; |
| 43 | } else if (strcmp("-d", argv[i]) == 0) { |
| 44 | duration_arg = true; |
| 45 | } |
| 46 | } |
| 47 | *enabled_tests_ptr++ = NULL; |
| 48 | } |
| 49 | |
| 50 | |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 51 | int main(int argc, char *argv[]) { |
Antoine Labour | ec7eb53 | 2010-03-12 11:01:34 -0800 | [diff] [blame] | 52 | SetBasePathFromArgv0(argv[0], "src"); |
Alexey Marinichev | 19b5a5d | 2010-02-18 11:37:26 -0800 | [diff] [blame] | 53 | ParseArgs(argc, argv); |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 54 | if (!Init()) { |
| 55 | printf("# Failed to initialize.\n"); |
| 56 | return 1; |
| 57 | } |
| 58 | |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame^] | 59 | glbench::TestBase* tests[] = { |
| 60 | glbench::GetSwapTest(), |
| 61 | glbench::GetClearTest(), |
| 62 | glbench::GetFillRateTest(), |
| 63 | glbench::GetYuvToRgbTest(1, "yuv_shader_1"), |
| 64 | glbench::GetYuvToRgbTest(2, "yuv_shader_2"), |
| 65 | glbench::GetReadPixelTest(), |
| 66 | glbench::GetTriangleSetupTest(), |
| 67 | glbench::GetAttributeFetchShaderTest(), |
| 68 | glbench::GetVaryingsAndDdxyShaderTest(), |
| 69 | glbench::GetWindowManagerCompositingTest(false), |
| 70 | glbench::GetWindowManagerCompositingTest(true), |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 71 | }; |
| 72 | |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame^] | 73 | for (unsigned int i = 0; i < arraysize(tests); i++) { |
| 74 | InitContext(); |
| 75 | tests[i]->Run(); |
| 76 | DestroyContext(); |
| 77 | delete tests[i]; |
| 78 | tests[i] = NULL; |
| 79 | } |
Alexey Marinichev | 592b862 | 2010-02-04 15:20:10 -0800 | [diff] [blame] | 80 | |
| 81 | return 0; |
| 82 | } |