• 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 "GLSLANG/ShaderLang.h"
8 #include "gtest/gtest.h"
9 #include "test_utils/runner/TestSuite.h"
10 
11 namespace
12 {
13 #if defined(ANGLE_ENABLE_VULKAN) || defined(ANGLE_ENABLE_METAL)
14 static constexpr bool kCanUseGlslang = true;
15 #else
16 static constexpr bool kCanUseGlslang = false;
17 #endif  // defined(ANGLE_ENABLE_VULKAN) || defined(ANGLE_ENABLE_METAL)
18 }  // anonymous namespace
19 
20 class CompilerTestEnvironment : public testing::Environment
21 {
22   public:
SetUp()23     void SetUp() override
24     {
25         if (kCanUseGlslang)
26         {
27             sh::InitializeGlslang();
28         }
29         if (!sh::Initialize())
30         {
31             FAIL() << "Failed to initialize the compiler.";
32         }
33     }
34 
TearDown()35     void TearDown() override
36     {
37         if (kCanUseGlslang)
38         {
39             sh::FinalizeGlslang();
40         }
41         if (!sh::Finalize())
42         {
43             FAIL() << "Failed to finalize the compiler.";
44         }
45     }
46 };
47 
48 // This variable is also defined in test_utils_unittest_helper.
49 bool gVerbose = false;
50 
main(int argc,char ** argv)51 int main(int argc, char **argv)
52 {
53     for (int argIndex = 1; argIndex < argc; ++argIndex)
54     {
55         if (strcmp(argv[argIndex], "-v") == 0 || strcmp(argv[argIndex], "--verbose") == 0)
56         {
57             gVerbose = true;
58         }
59     }
60 
61     angle::TestSuite testSuite(&argc, argv);
62     testing::AddGlobalTestEnvironment(new CompilerTestEnvironment());
63     return testSuite.run();
64 }
65