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