• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 The Khronos Group Inc.
3  * Copyright (c) 2021 Valve Corporation
4  * Copyright (c) 2021 LunarG, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and/or associated documentation files (the "Materials"), to
8  * deal in the Materials without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Materials, and to permit persons to whom the Materials are
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice(s) and this permission notice shall be included in
14  * all copies or substantial portions of the Materials.
15  *
16  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  *
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
23  * USE OR OTHER DEALINGS IN THE MATERIALS.
24  *
25  * Author: Charles Giessen <charles@lunarg.com>
26  */
27 
28 #include "test_environment.h"
29 
main(int argc,char ** argv)30 int main(int argc, char** argv) {
31 #if defined(_WIN32)
32     // Avoid "Abort, Retry, Ignore" dialog boxes
33     _set_error_mode(_OUT_TO_STDERR);
34     _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
35     SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
36     _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
37     _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
38     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
39     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
40     _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
41     _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
42 #endif
43 
44     // clean up folders from old test
45     fs::delete_folder(fs::path(FRAMEWORK_BUILD_DIRECTORY) / "null_dir");
46     fs::delete_folder(fs::path(FRAMEWORK_BUILD_DIRECTORY) / "icd_manifests");
47     fs::delete_folder(fs::path(FRAMEWORK_BUILD_DIRECTORY) / "portability_icd_manifests");
48     fs::delete_folder(fs::path(FRAMEWORK_BUILD_DIRECTORY) / "explicit_layer_manifests");
49     fs::delete_folder(fs::path(FRAMEWORK_BUILD_DIRECTORY) / "implicit_layer_manifests");
50 
51     // make sure the tests don't find these env-vars if they were set on the system
52     remove_env_var("VK_ICD_FILENAMES");
53     remove_env_var("VK_DRIVER_FILES");
54     remove_env_var("VK_ADD_DRIVER_FILES");
55     remove_env_var("VK_LAYER_PATH");
56     remove_env_var("VK_ADD_LAYER_PATH");
57     remove_env_var("VK_INSTANCE_LAYERS");
58     remove_env_var("VK_LOADER_DEBUG");
59     remove_env_var("VK_LOADER_DISABLE_INST_EXT_FILTER");
60 
61 #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
62     set_env_var("XDG_CONFIG_HOME", "/etc");
63     set_env_var("XDG_CONFIG_DIRS", "/etc");
64     set_env_var("XDG_DATA_HOME", "/etc");
65     set_env_var("XDG_DATA_DIRS", "/etc");
66 #endif
67 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
68     set_env_var("HOME", "/home/fake_home");
69 #endif
70 
71     ::testing::InitGoogleTest(&argc, argv);
72     int result = RUN_ALL_TESTS();
73 
74     return result;
75 }
76