Path: blob/main_old/src/tests/angle_unittest_main.cpp
1693 views
//1// Copyright 2013 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56#include "GLSLANG/ShaderLang.h"7#include "gtest/gtest.h"8#include "test_utils/runner/TestSuite.h"910namespace11{12#if defined(ANGLE_ENABLE_VULKAN) || defined(ANGLE_ENABLE_METAL)13static constexpr bool kCanUseGlslang = true;14#else15static constexpr bool kCanUseGlslang = false;16#endif // defined(ANGLE_ENABLE_VULKAN) || defined(ANGLE_ENABLE_METAL)17} // anonymous namespace1819class CompilerTestEnvironment : public testing::Environment20{21public:22void SetUp() override23{24if (kCanUseGlslang)25{26sh::InitializeGlslang();27}28if (!sh::Initialize())29{30FAIL() << "Failed to initialize the compiler.";31}32}3334void TearDown() override35{36if (kCanUseGlslang)37{38sh::FinalizeGlslang();39}40if (!sh::Finalize())41{42FAIL() << "Failed to finalize the compiler.";43}44}45};4647// This variable is also defined in test_utils_unittest_helper.48bool gVerbose = false;4950int main(int argc, char **argv)51{52for (int argIndex = 1; argIndex < argc; ++argIndex)53{54if (strcmp(argv[argIndex], "-v") == 0 || strcmp(argv[argIndex], "--verbose") == 0)55{56gVerbose = true;57}58}5960angle::TestSuite testSuite(&argc, argv);61testing::AddGlobalTestEnvironment(new CompilerTestEnvironment());62return testSuite.run();63}646566