OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/khronos_glcts_support/khronos_glcts_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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #if defined(OS_MACOSX) | |
16 #include "base/mac/scoped_nsautorelease_pool.h" | |
17 #endif | |
18 #include "base/path_service.h" | 15 #include "base/path_service.h" |
19 #include "base/process/launch.h" | 16 #include "base/process/launch.h" |
20 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
21 #include "gpu/config/gpu_test_config.h" | 18 #include "gpu/config/gpu_test_config.h" |
22 #include "gpu/config/gpu_test_expectations_parser.h" | 19 #include "gpu/config/gpu_test_expectations_parser.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
24 | 21 |
25 bool RunGLES2ConformTest(const char* path) { | 22 base::FilePath g_deqp_log_dir; |
| 23 |
| 24 bool RunKhronosGLCTSTest(const char* test_name) { |
26 // Load test expectations, and return early if a test is marked as FAIL. | 25 // Load test expectations, and return early if a test is marked as FAIL. |
27 base::FilePath src_path; | 26 base::FilePath src_path; |
28 PathService::Get(base::DIR_SOURCE_ROOT, &src_path); | 27 PathService::Get(base::DIR_SOURCE_ROOT, &src_path); |
29 base::FilePath test_expectations_path = | 28 base::FilePath test_expectations_path = |
30 src_path.Append(FILE_PATH_LITERAL("gpu")). | 29 src_path.Append(FILE_PATH_LITERAL("gpu")). |
31 Append(FILE_PATH_LITERAL("gles2_conform_support")). | 30 Append(FILE_PATH_LITERAL("khronos_glcts_support")). |
32 Append(FILE_PATH_LITERAL("gles2_conform_test_expectations.txt")); | 31 Append(FILE_PATH_LITERAL("khronos_glcts_test_expectations.txt")); |
33 if (!base::PathExists(test_expectations_path)) { | 32 if (!base::PathExists(test_expectations_path)) { |
34 LOG(ERROR) << "Fail to locate gles2_conform_test_expectations.txt"; | 33 LOG(ERROR) << "Fail to locate khronos_glcts_test_expectations.txt"; |
35 return false; | 34 return false; |
36 } | 35 } |
37 gpu::GPUTestExpectationsParser test_expectations; | 36 gpu::GPUTestExpectationsParser test_expectations; |
38 if (!test_expectations.LoadTestExpectations(test_expectations_path)) { | 37 if (!test_expectations.LoadTestExpectations(test_expectations_path)) { |
39 LOG(ERROR) << "Fail to load gles2_conform_test_expectations.txt"; | 38 LOG(ERROR) << "Fail to load khronos_glcts_test_expectations.txt"; |
40 return false; | 39 return false; |
41 } | 40 } |
42 gpu::GPUTestBotConfig bot_config; | 41 gpu::GPUTestBotConfig bot_config; |
43 if (!bot_config.LoadCurrentConfig(NULL)) { | 42 if (!bot_config.LoadCurrentConfig(NULL)) { |
44 LOG(ERROR) << "Fail to load bot configuration"; | 43 LOG(ERROR) << "Fail to load bot configuration"; |
45 return false; | 44 return false; |
46 } | 45 } |
47 if (!bot_config.IsValid()) { | 46 if (!bot_config.IsValid()) { |
48 LOG(ERROR) << "Invalid bot configuration"; | 47 LOG(ERROR) << "Invalid bot configuration"; |
49 return false; | 48 return false; |
50 } | 49 } |
51 std::string path_string(path); | 50 |
52 std::string test_name; | 51 const ::testing::TestInfo* const test_info = |
53 base::ReplaceChars(path_string, "\\/.", "_", &test_name); | 52 ::testing::UnitTest::GetInstance()->current_test_info(); |
54 int32 expectation = | 53 int32 expectation = |
55 test_expectations.GetTestExpectation(test_name, bot_config); | 54 test_expectations.GetTestExpectation(test_info->name(), bot_config); |
56 if (expectation != gpu::GPUTestExpectationsParser::kGpuTestPass) { | 55 if (expectation != gpu::GPUTestExpectationsParser::kGpuTestPass) { |
57 LOG(WARNING) << "Test " << test_name << " is bypassed"; | 56 LOG(WARNING) << "Test " << test_info->name() << " is bypassed"; |
58 return true; | 57 return true; |
59 } | 58 } |
60 | 59 |
61 base::FilePath test_path; | 60 base::FilePath test_path; |
62 PathService::Get(base::DIR_EXE, &test_path); | 61 PathService::Get(base::DIR_EXE, &test_path); |
| 62 base::FilePath archive(test_path.Append(FILE_PATH_LITERAL( |
| 63 "khronos_glcts_data"))); |
63 base::FilePath program(test_path.Append(FILE_PATH_LITERAL( | 64 base::FilePath program(test_path.Append(FILE_PATH_LITERAL( |
64 "gles2_conform_test_windowless"))); | 65 "khronos_glcts_test_windowless"))); |
| 66 base::FilePath log = |
| 67 g_deqp_log_dir.AppendASCII(test_info->name()). |
| 68 AddExtension(FILE_PATH_LITERAL(".log")); |
65 | 69 |
66 CommandLine* currentCmdLine = CommandLine::ForCurrentProcess(); | |
67 CommandLine cmdline(program); | 70 CommandLine cmdline(program); |
68 cmdline.AppendArguments(*currentCmdLine, false); | 71 cmdline.AppendSwitchPath("--deqp-log-filename", log); |
69 cmdline.AppendSwitch(std::string("--")); | 72 cmdline.AppendSwitchPath("--deqp-archive-dir", archive); |
70 cmdline.AppendArg(std::string("-run=") + path); | 73 cmdline.AppendArg("--deqp-gl-config-id=-1"); |
| 74 cmdline.AppendArg(std::string("--deqp-case=") + test_name); |
71 | 75 |
72 std::string output; | 76 std::string output; |
73 bool success = base::GetAppOutput(cmdline, &output); | 77 bool success = base::GetAppOutput(cmdline, &output); |
74 if (success) { | 78 if (success) { |
75 size_t success_index = output.find("Conformance PASSED all"); | 79 size_t success_index = output.find("Pass (Pass)"); |
76 size_t failed_index = output.find("FAILED"); | 80 size_t failed_index = output.find("Fail (Fail)"); |
77 success = (success_index != std::string::npos) && | 81 success = (success_index != std::string::npos) && |
78 (failed_index == std::string::npos); | 82 (failed_index == std::string::npos); |
79 } | 83 } |
80 if (!success) { | 84 if (!success) { |
81 LOG(ERROR) << output; | 85 LOG(ERROR) << output; |
82 } | 86 } |
83 return success; | 87 return success; |
84 } | 88 } |
85 | 89 |
86 int main(int argc, char** argv) { | 90 int main(int argc, char *argv[]) { |
87 base::AtExitManager exit_manager; | 91 base::AtExitManager at_exit; |
88 CommandLine::Init(argc, argv); | 92 |
89 #if defined(OS_MACOSX) | |
90 base::mac::ScopedNSAutoreleasePool pool; | |
91 #endif | |
92 ::testing::InitGoogleTest(&argc, argv); | 93 ::testing::InitGoogleTest(&argc, argv); |
| 94 |
| 95 if (argc == 2) { |
| 96 g_deqp_log_dir = base::FilePath::FromUTF8Unsafe(argv[1]); |
| 97 } |
| 98 else { |
| 99 base::GetTempDir(&g_deqp_log_dir); |
| 100 } |
| 101 |
93 return RUN_ALL_TESTS(); | 102 return RUN_ALL_TESTS(); |
94 } | 103 } |
95 | 104 |
96 | |
97 | |
OLD | NEW |