OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium 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 "gpu/gles2_conform_support/gles2_conform_test.h" | 5 #include "gpu/gles2_conform_support/gles2_conform_test.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 gpu::GPUTestExpectationsParser test_expectations; | 37 gpu::GPUTestExpectationsParser test_expectations; |
38 if (!test_expectations.LoadTestExpectations(test_expectations_path)) { | 38 if (!test_expectations.LoadTestExpectations(test_expectations_path)) { |
39 LOG(ERROR) << "Fail to load gles2_conform_test_expectations.txt"; | 39 LOG(ERROR) << "Fail to load gles2_conform_test_expectations.txt"; |
40 return false; | 40 return false; |
41 } | 41 } |
42 gpu::GPUTestBotConfig bot_config; | 42 gpu::GPUTestBotConfig bot_config; |
43 if (!bot_config.LoadCurrentConfig(NULL)) { | 43 if (!bot_config.LoadCurrentConfig(NULL)) { |
44 LOG(ERROR) << "Fail to load bot configuration"; | 44 LOG(ERROR) << "Fail to load bot configuration"; |
45 return false; | 45 return false; |
46 } | 46 } |
| 47 |
| 48 // Set the bot config api based on the OS and command line |
| 49 base::CommandLine* current_cmd_line = base::CommandLine::ForCurrentProcess(); |
| 50 int32 config_os = bot_config.os(); |
| 51 if ((config_os & gpu::GPUTestConfig::kOsWin) != 0) { |
| 52 std::string angle_renderer = |
| 53 current_cmd_line->HasSwitch("use-angle") |
| 54 ? current_cmd_line->GetSwitchValueASCII("use-angle") |
| 55 : "d3d11"; |
| 56 if (angle_renderer == "d3d11") { |
| 57 bot_config.set_api(gpu::GPUTestConfig::kAPID3D11); |
| 58 } else if (angle_renderer == "d3d9") { |
| 59 bot_config.set_api(gpu::GPUTestConfig::kAPID3D9); |
| 60 } else if (angle_renderer == "gl") { |
| 61 bot_config.set_api(gpu::GPUTestConfig::kAPIGLDesktop); |
| 62 } else if (angle_renderer == "gles") { |
| 63 bot_config.set_api(gpu::GPUTestConfig::kAPIGLES); |
| 64 } else { |
| 65 bot_config.set_api(gpu::GPUTestConfig::kAPIUnknown); |
| 66 } |
| 67 } else if ((config_os & gpu::GPUTestConfig::kOsMac) != 0 || |
| 68 config_os == gpu::GPUTestConfig::kOsLinux) { |
| 69 bot_config.set_api(gpu::GPUTestConfig::kAPIGLDesktop); |
| 70 } else if (config_os == gpu::GPUTestConfig::kOsChromeOS || |
| 71 config_os == gpu::GPUTestConfig::kOsAndroid) { |
| 72 bot_config.set_api(gpu::GPUTestConfig::kAPIGLES); |
| 73 } else { |
| 74 bot_config.set_api(gpu::GPUTestConfig::kAPIUnknown); |
| 75 } |
| 76 |
47 if (!bot_config.IsValid()) { | 77 if (!bot_config.IsValid()) { |
48 LOG(ERROR) << "Invalid bot configuration"; | 78 LOG(ERROR) << "Invalid bot configuration"; |
49 return false; | 79 return false; |
50 } | 80 } |
51 std::string path_string(path); | 81 std::string path_string(path); |
52 std::string test_name; | 82 std::string test_name; |
53 base::ReplaceChars(path_string, "\\/.", "_", &test_name); | 83 base::ReplaceChars(path_string, "\\/.", "_", &test_name); |
54 int32 expectation = | 84 int32 expectation = |
55 test_expectations.GetTestExpectation(test_name, bot_config); | 85 test_expectations.GetTestExpectation(test_name, bot_config); |
56 if (expectation != gpu::GPUTestExpectationsParser::kGpuTestPass) { | 86 if (expectation != gpu::GPUTestExpectationsParser::kGpuTestPass) { |
57 LOG(WARNING) << "Test " << test_name << " is bypassed"; | 87 LOG(WARNING) << "Test " << test_name << " is bypassed"; |
58 return true; | 88 return true; |
59 } | 89 } |
60 | 90 |
61 base::FilePath test_path; | 91 base::FilePath test_path; |
62 PathService::Get(base::DIR_EXE, &test_path); | 92 PathService::Get(base::DIR_EXE, &test_path); |
63 base::FilePath program(test_path.Append(FILE_PATH_LITERAL( | 93 base::FilePath program(test_path.Append(FILE_PATH_LITERAL( |
64 "gles2_conform_test_windowless"))); | 94 "gles2_conform_test_windowless"))); |
65 | 95 |
66 base::CommandLine* currentCmdLine = base::CommandLine::ForCurrentProcess(); | 96 base::CommandLine cmd_line(program); |
67 base::CommandLine cmdline(program); | 97 cmd_line.AppendArguments(*current_cmd_line, false); |
68 cmdline.AppendArguments(*currentCmdLine, false); | 98 cmd_line.AppendSwitch(std::string("--")); |
69 cmdline.AppendSwitch(std::string("--")); | 99 cmd_line.AppendArg(std::string("-run=") + path); |
70 cmdline.AppendArg(std::string("-run=") + path); | |
71 | 100 |
72 std::string output; | 101 std::string output; |
73 bool success = base::GetAppOutput(cmdline, &output); | 102 bool success = base::GetAppOutput(cmd_line, &output); |
74 if (success) { | 103 if (success) { |
75 size_t success_index = output.find("Conformance PASSED all"); | 104 size_t success_index = output.find("Conformance PASSED all"); |
76 size_t failed_index = output.find("FAILED"); | 105 size_t failed_index = output.find("FAILED"); |
77 success = (success_index != std::string::npos) && | 106 success = (success_index != std::string::npos) && |
78 (failed_index == std::string::npos); | 107 (failed_index == std::string::npos); |
79 } | 108 } |
80 if (!success) { | 109 if (!success) { |
81 LOG(ERROR) << output; | 110 LOG(ERROR) << output; |
82 } | 111 } |
83 return success; | 112 return success; |
84 } | 113 } |
85 | 114 |
86 int main(int argc, char** argv) { | 115 int main(int argc, char** argv) { |
87 base::AtExitManager exit_manager; | 116 base::AtExitManager exit_manager; |
88 base::CommandLine::Init(argc, argv); | 117 base::CommandLine::Init(argc, argv); |
89 #if defined(OS_MACOSX) | 118 #if defined(OS_MACOSX) |
90 base::mac::ScopedNSAutoreleasePool pool; | 119 base::mac::ScopedNSAutoreleasePool pool; |
91 #endif | 120 #endif |
92 ::testing::InitGoogleTest(&argc, argv); | 121 ::testing::InitGoogleTest(&argc, argv); |
93 return RUN_ALL_TESTS(); | 122 return RUN_ALL_TESTS(); |
94 } | 123 } |
95 | 124 |
96 | 125 |
97 | 126 |
OLD | NEW |