From 7879c955b9a8705576d975a9d1bbd280ca40ade8 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Thu, 15 Jun 2023 14:05:59 -0600 Subject: test: Add test infrastructure Add necessary CMake code to enable tests to be built and run. Most of the logic is taken from Vulkan-ValidationLayers' and adapted for use here. New build option: BUILD_TESTS - defaults to OFF. Controls whether to build tests. --- tests/main.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/main.cpp (limited to 'tests/main.cpp') diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 00000000..a14e8e99 --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 The Khronos Group Inc. + * Copyright (c) 2023 Valve Corporation + * Copyright (c) 2023 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#if defined(_WIN32) && !defined(NDEBUG) +#include +#endif + +#include "gtest/gtest.h" + +int main(int argc, char **argv) { + int result; + +#if defined(_WIN32) +#if !defined(NDEBUG) + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); +#endif + // Avoid "Abort, Retry, Ignore" dialog boxes + _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); + SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); +#endif + + ::testing::InitGoogleTest(&argc, argv); + + result = RUN_ALL_TESTS(); + + return result; +} -- cgit v1.2.3