Remove errant '>' in gyp file.
[chromium-blink-merge.git] / gpu / khronos_glcts_support / khronos_glcts_test.cc
blob287b5d02587831d55677315f497e30203e4c9b4d
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
3 // found in the LICENSE file.
5 #include "gpu/khronos_glcts_support/khronos_glcts_test.h"
7 #include <string>
9 #include "base/at_exit.h"
10 #include "base/base_paths.h"
11 #include "base/command_line.h"
12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h"
14 #include "base/logging.h"
15 #include "base/path_service.h"
16 #include "base/process/launch.h"
17 #include "base/strings/string_util.h"
18 #include "gpu/config/gpu_test_config.h"
19 #include "gpu/config/gpu_test_expectations_parser.h"
20 #include "testing/gtest/include/gtest/gtest.h"
22 base::FilePath g_deqp_log_dir;
24 bool RunKhronosGLCTSTest(const char* test_name) {
25 // Load test expectations, and return early if a test is marked as FAIL.
26 base::FilePath src_path;
27 PathService::Get(base::DIR_SOURCE_ROOT, &src_path);
28 base::FilePath test_expectations_path =
29 src_path.Append(FILE_PATH_LITERAL("gpu")).
30 Append(FILE_PATH_LITERAL("khronos_glcts_support")).
31 Append(FILE_PATH_LITERAL("khronos_glcts_test_expectations.txt"));
32 if (!base::PathExists(test_expectations_path)) {
33 LOG(ERROR) << "Fail to locate khronos_glcts_test_expectations.txt";
34 return false;
36 gpu::GPUTestExpectationsParser test_expectations;
37 if (!test_expectations.LoadTestExpectations(test_expectations_path)) {
38 LOG(ERROR) << "Fail to load khronos_glcts_test_expectations.txt";
39 return false;
41 gpu::GPUTestBotConfig bot_config;
42 if (!bot_config.LoadCurrentConfig(NULL)) {
43 LOG(ERROR) << "Fail to load bot configuration";
44 return false;
46 if (!bot_config.IsValid()) {
47 LOG(ERROR) << "Invalid bot configuration";
48 return false;
51 const ::testing::TestInfo* const test_info =
52 ::testing::UnitTest::GetInstance()->current_test_info();
53 int32 expectation =
54 test_expectations.GetTestExpectation(test_info->name(), bot_config);
55 if (expectation != gpu::GPUTestExpectationsParser::kGpuTestPass) {
56 LOG(WARNING) << "Test " << test_info->name() << " is bypassed";
57 return true;
60 base::FilePath test_path;
61 PathService::Get(base::DIR_EXE, &test_path);
62 base::FilePath archive(test_path.Append(FILE_PATH_LITERAL(
63 "khronos_glcts_data")));
64 base::FilePath program(test_path.Append(FILE_PATH_LITERAL(
65 "khronos_glcts_test_windowless")));
66 base::FilePath log =
67 g_deqp_log_dir.AppendASCII(test_info->name()).
68 AddExtension(FILE_PATH_LITERAL(".log"));
70 base::CommandLine cmdline(program);
71 cmdline.AppendSwitchPath("--deqp-log-filename", log);
72 cmdline.AppendSwitchPath("--deqp-archive-dir", archive);
73 cmdline.AppendArg("--deqp-gl-config-id=-1");
74 cmdline.AppendArg(std::string("--deqp-case=") + test_name);
76 std::string output;
77 bool success = base::GetAppOutput(cmdline, &output);
78 if (success) {
79 size_t success_index = output.find("Pass (Pass)");
80 size_t failed_index = output.find("Fail (Fail)");
81 success = (success_index != std::string::npos) &&
82 (failed_index == std::string::npos);
84 if (!success) {
85 LOG(ERROR) << output;
87 return success;
90 int main(int argc, char *argv[]) {
91 base::AtExitManager at_exit;
93 ::testing::InitGoogleTest(&argc, argv);
95 if (argc == 2) {
96 g_deqp_log_dir = base::FilePath::FromUTF8Unsafe(argv[1]);
98 else {
99 base::GetTempDir(&g_deqp_log_dir);
102 return RUN_ALL_TESTS();