1 /*
2  * Copyright (C) 2021 Intel Corporation
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  */
7 
8 #include "shared/test/common/test_macros/test_excludes.h"
9 
10 #include "shared/source/helpers/debug_helpers.h"
11 
12 #include <map>
13 #include <memory>
14 #include <string>
15 #include <unordered_set>
16 
17 using namespace NEO;
18 
19 GFXCORE_FAMILY renderCoreFamily = {};
20 
21 static std::unique_ptr<std::map<std::string, std::unordered_set<uint32_t>>> pProductExcludesPerTest;
22 static std::unique_ptr<std::map<std::string, std::unordered_set<uint32_t>>> pGfxExcludesPerTest;
23 
isExcluded(const char * testName,const uint32_t family,std::unique_ptr<std::map<std::string,std::unordered_set<uint32_t>>> & pExcludesPerTest)24 bool isExcluded(const char *testName, const uint32_t family, std::unique_ptr<std::map<std::string, std::unordered_set<uint32_t>>> &pExcludesPerTest) {
25     if ((pExcludesPerTest == nullptr) || pExcludesPerTest->count(testName) == 0) {
26         return false;
27     }
28     return (pExcludesPerTest->at(testName).count(family) > 0);
29 }
30 
addExclude(const char * testName,const uint32_t family,std::unique_ptr<std::map<std::string,std::unordered_set<uint32_t>>> & pExcludesPerTest)31 void addExclude(const char *testName, const uint32_t family, std::unique_ptr<std::map<std::string, std::unordered_set<uint32_t>>> &pExcludesPerTest) {
32     if (pExcludesPerTest == nullptr) {
33         pExcludesPerTest = std::make_unique<std::map<std::string, std::unordered_set<uint32_t>>>();
34     }
35     if (pExcludesPerTest->count(testName) == 0) {
36         pExcludesPerTest->insert(std::make_pair(testName, std::unordered_set<uint32_t>{}));
37     }
38     pExcludesPerTest->at(testName).insert(family);
39 }
40 
isTestExcluded(const char * testName,const PRODUCT_FAMILY productFamily,const GFXCORE_FAMILY gfxFamily)41 bool TestExcludes::isTestExcluded(const char *testName, const PRODUCT_FAMILY productFamily, const GFXCORE_FAMILY gfxFamily) {
42     return (isExcluded(testName, productFamily, pProductExcludesPerTest) || isExcluded(testName, gfxFamily, pGfxExcludesPerTest));
43 }
44 
addTestExclude(const char * testName,const PRODUCT_FAMILY family)45 void TestExcludes::addTestExclude(const char *testName, const PRODUCT_FAMILY family) {
46     addExclude(testName, family, pProductExcludesPerTest);
47 }
48 
addTestExclude(const char * testName,const GFXCORE_FAMILY family)49 void TestExcludes::addTestExclude(const char *testName, const GFXCORE_FAMILY family) {
50     addExclude(testName, family, pGfxExcludesPerTest);
51 }
52