• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015-2016 The Khronos Group Inc.
3  * Copyright (c) 2015-2016 Valve Corporation
4  * Copyright (c) 2015-2016 LunarG, Inc.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
19  * Author: Tony Barbour <tony@LunarG.com>
20  */
21 
22 #ifndef VKTESTFRAMEWORK_H
23 #define VKTESTFRAMEWORK_H
24 
25 //#include "gtest-1.7.0/include/gtest/gtest.h"
26 #include "SPIRV/GLSL.std.450.h"
27 #include "glslang/Public/ShaderLang.h"
28 #include "icd-spv.h"
29 #include "test_common.h"
30 #include "test_environment.h"
31 #include "vktestbinding.h"
32 
33 #include <fstream>
34 #include <iostream>
35 #include <list>
36 #include <stdbool.h>
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40 
41 #ifdef _WIN32
42 #ifndef WIN32_LEAN_AND_MEAN
43 #define WIN32_LEAN_AND_MEAN
44 #endif
45 #include <windows.h>
46 #endif
47 
48 #if defined(NDEBUG) && defined(__GNUC__)
49 #define U_ASSERT_ONLY __attribute__((unused))
50 #else
51 #define U_ASSERT_ONLY
52 #endif
53 
54 // Can be used by tests to record additional details / description of test
55 #define TEST_DESCRIPTION(desc) RecordProperty("description", desc)
56 
57 using namespace std;
58 
59 class VkImageObj;
60 
61 class VkTestFramework : public ::testing::Test {
62   public:
63     VkTestFramework();
64     ~VkTestFramework();
65 
66     VkFormat GetFormat(VkInstance instance, vk_testing::Device *device);
67     static bool optionMatch(const char *option, char *optionLine);
68     static void InitArgs(int *argc, char *argv[]);
69     static void Finish();
70 
71     bool GLSLtoSPV(const VkShaderStageFlagBits shader_type, const char *pshader, std::vector<unsigned int> &spv);
72     static bool m_use_glsl;
73     static bool m_canonicalize_spv;
74     static bool m_strip_spv;
75     static bool m_do_everything_spv;
76 
77     char **ReadFileData(const char *fileName);
78     void FreeFileData(char **data);
79 
80   private:
81     int m_compile_options;
82     int m_num_shader_strings;
83     TBuiltInResource Resources;
84     void SetMessageOptions(EShMessages &messages);
85     void ProcessConfigFile();
86     EShLanguage FindLanguage(const std::string &name);
87     EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type);
88     std::string ConfigFile;
89     bool SetConfigFile(const std::string &name);
90     static int m_width;
91     static int m_height;
92     string m_testName;
93 };
94 
95 class TestEnvironment : public ::testing::Environment {
96   public:
97     void SetUp();
98 
99     void TearDown();
100 };
101 
102 #endif // VKTESTFRAMEWORK_H
103