1 #ifndef _TCUWAIVERUTIL_HPP
2 #define _TCUWAIVERUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan CTS Framework
5  * --------------------
6  *
7  * Copyright (c) 2020 The Khronos Group Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Waiver mechanism implementation.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "deDefs.h"
27 #include <sstream>
28 #include <vector>
29 
30 namespace tcu
31 {
32 
33 // Class containing information about session that are printed at the beginning of log.
34 class SessionInfo
35 {
36 public:
37 
38 					SessionInfo		(deUint32				vendorId,
39 									 deUint32				deviceId,
40 									 const std::string&		cmdLine);
41 					SessionInfo		(std::string			vendor,
42 									 std::string			renderer,
43 									 const std::string&		cmdLine);
44 
45 	std::string		get				();
46 
47 private:
48 
49 	// WaiverTreeBuilder fills private fields of this class.
50 	friend class WaiverTreeBuilder;
51 
52 	// String containing urls to gitlab issues
53 	// that enable currently used waivers
54 	std::string			m_waiverUrls;
55 
56 	// String containing command line
57 	std::string			m_cmdLine;
58 
59 	// Stream containing all info
60 	std::stringstream	m_info;
61 };
62 
63 // Class that uses paths to waived tests represented in a form of tree.
64 // Main functionality of this class is to quickly test test paths in
65 // order to verify if it is on waived tests list that was read from xml.
66 class WaiverUtil
67 {
68 public:
69 			WaiverUtil		() = default;
70 
71 	void	setup			(const std::string	waiverFile,
72 							 std::string		packageName,
73 							 deUint32			vendorId,
74 							 deUint32			deviceId,
75 							 SessionInfo&		sessionInfo);
76 	void	setup			(const std::string	waiverFile,
77 							 std::string		packageName,
78 							 std::string		vendor,
79 							 std::string		renderer,
80 							 SessionInfo&		sessionInfo);
81 
82 	bool	isOnWaiverList	(const std::string& casePath) const;
83 
84 public:
85 
86 	struct WaiverComponent
87 	{
88 		std::string						name;
89 		std::vector<WaiverComponent*>	children;
90 	};
91 
92 private:
93 
94 	std::vector<WaiverComponent> m_waiverTree;
95 };
96 
97 } // tcu
98 
99 #endif // _TCUWAIVERUTIL_HPP
100