diff options
| author | Charles Giessen <charles@lunarg.com> | 2023-06-15 14:05:59 -0600 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2023-06-16 15:06:03 -0600 |
| commit | 7879c955b9a8705576d975a9d1bbd280ca40ade8 (patch) | |
| tree | c7501d7daac6507fd6163e288dc53d16737e1022 /tests/main.cpp | |
| parent | 0d43b2471174e5bb6d5d8061e5f69c609c84ad5d (diff) | |
| download | usermoji-7879c955b9a8705576d975a9d1bbd280ca40ade8.tar.xz | |
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.
Diffstat (limited to 'tests/main.cpp')
| -rw-r--r-- | tests/main.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
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 <crtdbg.h> +#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; +} |
