blob: 5f9a43132ccb1baa62e893563660e90cc96da0c0 [file] [log] [blame]
Alexey Marinichev592b8622010-02-04 15:20:10 -08001// 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 Marinichev6294a392010-03-02 16:53:36 -08005#include <fcntl.h>
Alexey Marinichev592b8622010-02-04 15:20:10 -08006#include <stdio.h>
7#include <stdlib.h>
Alexey Marinichev19b5a5d2010-02-18 11:37:26 -08008#include <string.h>
Alexey Marinichev6294a392010-03-02 16:53:36 -08009#include <sys/mman.h>
Alexey Marinichev592b8622010-02-04 15:20:10 -080010
Alexey Marinichevaf0b26d2010-02-24 13:03:13 -080011#include "base/logging.h"
12
Alexey Marinichev592b8622010-02-04 15:20:10 -080013#include "main.h"
Alexey Marinichev3c199732010-03-11 10:33:35 -080014#include "utils.h"
Alexey Marinichev6294a392010-03-02 16:53:36 -080015#include "yuv2rgb.h"
Alexey Marinichev592b8622010-02-04 15:20:10 -080016
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070017#include "all_tests.h"
18#include "testbase.h"
19
Alexey Marinichev592b8622010-02-04 15:20:10 -080020
Darin Petkovdd314962010-02-18 16:21:29 -080021const int enabled_tests_max = 8;
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070022// TODO: fix enabled_tests.
Alexey Marinichev19b5a5d2010-02-18 11:37:26 -080023const char *enabled_tests[enabled_tests_max+1] = {NULL};
24int seconds_to_run = 0;
25
Alexey Marinichev0f9aa1b2010-03-30 14:38:16 -070026
Alexey Marinichev19b5a5d2010-02-18 11:37:26 -080027// TODO: use proper command line parsing library.
28static 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 Marinichev592b8622010-02-04 15:20:10 -080051int main(int argc, char *argv[]) {
Antoine Labourec7eb532010-03-12 11:01:34 -080052 SetBasePathFromArgv0(argv[0], "src");
Alexey Marinichev19b5a5d2010-02-18 11:37:26 -080053 ParseArgs(argc, argv);
Alexey Marinichev592b8622010-02-04 15:20:10 -080054 if (!Init()) {
55 printf("# Failed to initialize.\n");
56 return 1;
57 }
58
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070059 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 Marinichev592b8622010-02-04 15:20:10 -080071 };
72
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070073 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 Marinichev592b8622010-02-04 15:20:10 -080080
81 return 0;
82}