• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2013 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #include "gtest/gtest.h"
8 #include "test_utils/runner/TestSuite.h"
9 #include "util/OSWindow.h"
10 
11 void ANGLEProcessTestArgs(int *argc, char *argv[]);
12 
13 // Register* functions handle setting up special tests that need complex parameterization.
14 // GoogleTest relies heavily on static initialization to register test functions. This can
15 // cause all sorts of issues if the right variables aren't initialized in the right order.
16 // This register function needs to be called explicitly after static initialization and
17 // before the test launcher starts. This is a safer and generally better way to initialize
18 // tests. It's also more similar to how the dEQP Test harness works. In the future we should
19 // likely specialize more register functions more like dEQP instead of relying on static init.
20 void RegisterContextCompatibilityTests();
21 
22 namespace
23 {
24 constexpr char kTestExpectationsPath[] = "src/tests/angle_end2end_tests_expectations.txt";
25 
HasArg(int argc,char ** argv,const char * arg)26 bool HasArg(int argc, char **argv, const char *arg)
27 {
28     for (int i = 1; i < argc; ++i)
29     {
30         if (strstr(argv[i], arg) != nullptr)
31         {
32             return true;
33         }
34     }
35     return false;
36 }
37 }  // namespace
38 
main(int argc,char ** argv)39 int main(int argc, char **argv)
40 {
41     if (!HasArg(argc, argv, "--list-tests") && !HasArg(argc, argv, "--gtest_list_tests") &&
42         HasArg(argc, argv, "--use-gl"))
43     {
44         std::cerr << "--use-gl isn't supported by end2end tests - use *_EGL configs instead "
45                      "(angle_test_enable_system_egl=true)\n";
46         return EXIT_FAILURE;
47     }
48 
49     auto registerTestsCallback = [] {
50         if (!IsTSan())
51         {
52             RegisterContextCompatibilityTests();
53         }
54     };
55     angle::TestSuite testSuite(&argc, argv, registerTestsCallback);
56     ANGLEProcessTestArgs(&argc, argv);
57 
58     constexpr size_t kMaxPath = 512;
59     std::array<char, kMaxPath> foundDataPath;
60     if (!angle::FindTestDataPath(kTestExpectationsPath, foundDataPath.data(), foundDataPath.size()))
61     {
62         std::cerr << "Unable to find test expectations path (" << kTestExpectationsPath << ")\n";
63         return EXIT_FAILURE;
64     }
65 
66     // end2end test expectations only allow SKIP at the moment.
67     testSuite.setTestExpectationsAllowMask(angle::GPUTestExpectationsParser::kGpuTestSkip |
68                                            angle::GPUTestExpectationsParser::kGpuTestTimeout);
69 
70     if (!testSuite.loadAllTestExpectationsFromFile(std::string(foundDataPath.data())))
71     {
72         return EXIT_FAILURE;
73     }
74 
75     return testSuite.run();
76 }
77