Home | History | Annotate | Download | only in tests
      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 (at) LunarG.com>
     19  * Author: Tony Barbour <tony (at) 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 
     32 #include <fstream>
     33 #include <iostream>
     34 #include <list>
     35 #include <stdbool.h>
     36 #include <stdio.h>
     37 #include <stdlib.h>
     38 #include <string.h>
     39 
     40 #ifdef _WIN32
     41 #ifndef WIN32_LEAN_AND_MEAN
     42 #define WIN32_LEAN_AND_MEAN
     43 #endif
     44 #include <windows.h>
     45 #endif
     46 
     47 #if defined(NDEBUG) && defined(__GNUC__)
     48 #define U_ASSERT_ONLY __attribute__((unused))
     49 #else
     50 #define U_ASSERT_ONLY
     51 #endif
     52 
     53 // Can be used by tests to record additional details / description of test
     54 #define TEST_DESCRIPTION(desc) RecordProperty("description", desc)
     55 
     56 using namespace std;
     57 
     58 class VkImageObj;
     59 
     60 class VkTestFramework : public ::testing::Test {
     61    public:
     62     VkTestFramework();
     63     ~VkTestFramework();
     64 
     65     VkFormat GetFormat(VkInstance instance, vk_testing::Device *device);
     66     static bool optionMatch(const char *option, char *optionLine);
     67     static void InitArgs(int *argc, char *argv[]);
     68     static void Finish();
     69 
     70     bool GLSLtoSPV(const VkShaderStageFlagBits shader_type, const char *pshader, std::vector<unsigned int> &spv);
     71     static bool m_canonicalize_spv;
     72     static bool m_strip_spv;
     73     static bool m_do_everything_spv;
     74     static bool m_devsim_layer;
     75 
     76     char **ReadFileData(const char *fileName);
     77     void FreeFileData(char **data);
     78 
     79    private:
     80     int m_compile_options;
     81     int m_num_shader_strings;
     82     TBuiltInResource Resources;
     83     void SetMessageOptions(EShMessages &messages);
     84     void ProcessConfigFile();
     85     EShLanguage FindLanguage(const std::string &name);
     86     EShLanguage FindLanguage(const VkShaderStageFlagBits shader_type);
     87     std::string ConfigFile;
     88     bool SetConfigFile(const std::string &name);
     89     static int m_width;
     90     static int m_height;
     91     string m_testName;
     92 };
     93 
     94 class TestEnvironment : public ::testing::Environment {
     95    public:
     96     void SetUp();
     97 
     98     void TearDown();
     99 };
    100 
    101 #endif  // VKTESTFRAMEWORK_H
    102