Merge "Properly clean up data in buffer upload test deinit()."
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / vktTestGroupUtil.hpp
1 #ifndef _VKTTESTGROUPUTIL_HPP
2 #define _VKTTESTGROUPUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2016 Google Inc.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and/or associated documentation files (the
11  * "Materials"), to deal in the Materials without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Materials, and to
14  * permit persons to whom the Materials are furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice(s) and this permission notice shall be
18  * included in all copies or substantial portions of the Materials.
19  *
20  * The Materials are Confidential Information as defined by the
21  * Khronos Membership Agreement until designated non-confidential by
22  * Khronos, at which point this condition clause shall be removed.
23  *
24  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
31  *
32  *//*!
33  * \file
34  * \brief TestCaseGroup utilities
35  *//*--------------------------------------------------------------------*/
36
37 #include "tcuDefs.hpp"
38 #include "tcuTestCase.hpp"
39
40 namespace vkt
41 {
42
43 class TestGroupHelper0 : public tcu::TestCaseGroup
44 {
45 public:
46         typedef void (*CreateChildrenFunc) (tcu::TestCaseGroup* testGroup);
47
48                                                                 TestGroupHelper0        (tcu::TestContext&              testCtx,
49                                                                                                          const std::string&             name,
50                                                                                                          const std::string&             description,
51                                                                                                          CreateChildrenFunc             createChildren);
52                                                                 ~TestGroupHelper0       (void);
53
54         void                                            init                            (void);
55
56 private:
57         const CreateChildrenFunc        m_createChildren;
58 };
59
60 template<typename Arg0>
61 class TestGroupHelper1 : public tcu::TestCaseGroup
62 {
63 public:
64         typedef void (*CreateChildrenFunc) (tcu::TestCaseGroup* testGroup, Arg0 arg0);
65
66                                                                 TestGroupHelper1        (tcu::TestContext&              testCtx,
67                                                                                                          const std::string&             name,
68                                                                                                          const std::string&             description,
69                                                                                                          CreateChildrenFunc             createChildren,
70                                                                                                          const Arg0&                    arg0)
71                                                                         : tcu::TestCaseGroup    (testCtx, name.c_str(), description.c_str())
72                                                                         , m_createChildren              (createChildren)
73                                                                         , m_arg0                                (arg0)
74                                                                 {}
75
76         void                                            init                            (void) { m_createChildren(this, m_arg0); }
77
78 private:
79         const CreateChildrenFunc        m_createChildren;
80         const Arg0                                      m_arg0;
81 };
82
83 inline tcu::TestCaseGroup* createTestGroup (tcu::TestContext&                                           testCtx,
84                                                                                         const std::string&                                              name,
85                                                                                         const std::string&                                              description,
86                                                                                         TestGroupHelper0::CreateChildrenFunc    createChildren)
87 {
88         return new TestGroupHelper0(testCtx, name, description, createChildren);
89 }
90
91 template<typename Arg0>
92 tcu::TestCaseGroup* createTestGroup (tcu::TestContext&                                                                          testCtx,
93                                                                          const std::string&                                                                             name,
94                                                                          const std::string&                                                                             description,
95                                                                          typename TestGroupHelper1<Arg0>::CreateChildrenFunc    createChildren,
96                                                                          Arg0                                                                                                   arg0)
97 {
98         return new TestGroupHelper1<Arg0>(testCtx, name, description, createChildren, arg0);
99 }
100
101 } // vkt
102
103 #endif // _VKTTESTGROUPUTIL_HPP