tests: Use global SetUp/TearDown for compiler setup
The GLSL compiler requires some one-time per process setup and
teardown to operate properly. Using gtest global environment to
manage those functions.
diff --git a/tests/render_tests.cpp b/tests/render_tests.cpp
index 3427815..7d0e628 100644
--- a/tests/render_tests.cpp
+++ b/tests/render_tests.cpp
@@ -1174,6 +1174,8 @@
::testing::InitGoogleTest(&argc, argv);
XglTestFramework::InitArgs(&argc, argv);
+ ::testing::Environment* const xgl_test_env = ::testing::AddGlobalTestEnvironment(new TestEnvironment);
+
result = RUN_ALL_TESTS();
XglTestFramework::Finish();
diff --git a/tests/xgltestframework.cpp b/tests/xgltestframework.cpp
index 917f031..8015cb0 100644
--- a/tests/xgltestframework.cpp
+++ b/tests/xgltestframework.cpp
@@ -73,19 +73,30 @@
#endif
+// Set up environment for GLSL compiler
+// Must be done once per process
+void TestEnvironment::SetUp()
+{
+ // Initialize GLSL to BIL compiler utility
+ glslang::InitializeProcess();
+}
+
+void TestEnvironment::TearDown()
+{
+ glslang::FinalizeProcess();
+}
+
XglTestFramework::XglTestFramework() :
m_glut_initialized( false ),
m_compile_options( 0 ),
m_num_shader_strings( 0 )
{
- // Initialize GLSL to BIL compiler utility
-// ShInitialize();
- glslang::InitializeProcess();
+
}
XglTestFramework::~XglTestFramework()
{
- glslang::FinalizeProcess();
+
}
// Define all the static elements
diff --git a/tests/xgltestframework.h b/tests/xgltestframework.h
index c483b96..8e8d45b 100644
--- a/tests/xgltestframework.h
+++ b/tests/xgltestframework.h
@@ -102,4 +102,12 @@
static int m_height; // Window height
};
+class TestEnvironment : public ::testing::Environment
+{
+ public:
+ void SetUp();
+
+ void TearDown();
+};
+
#endif // XGLTESTFRAMEWORK_H