Refactor product config helper

This commit brings order to the product config helper
code and corrects the naming

Signed-off-by: Daria Hinz <daria.hinz@intel.com>
This commit is contained in:
Daria Hinz
2022-11-16 16:30:56 +00:00
committed by Compute-Runtime-Automation
parent e197736b6f
commit ab6e989eb3
11 changed files with 84 additions and 38 deletions

View File

@@ -39,6 +39,7 @@ target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/memory_management_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_properties_helpers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/product_config_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/product_config_helper_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/ptr_math_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ray_tracing_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address_tests.cpp

View File

@@ -5,7 +5,8 @@
*
*/
#include "shared/source/helpers/product_config_helper.h"
#include "shared/test/unit_test/helpers/product_config_helper_tests.h"
#include "shared/source/utilities/const_stringref.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/test_macros/test.h"
@@ -14,10 +15,8 @@
#include <algorithm>
using ProductConfigHelperTests = ::testing::Test;
TEST_F(ProductConfigHelperTests, givenProductAcronymWhenHelperSearchForAMatchThenCorrespondingValueIsReturned) {
for (const auto &[acronym, value] : AOT::productConfigAcronyms) {
for (const auto &[acronym, value] : AOT::deviceAcronyms) {
EXPECT_EQ(ProductConfigHelper::getProductConfigForAcronym(acronym), value);
}
}
@@ -87,7 +86,7 @@ TEST_F(ProductConfigHelperTests, givenDeviceStringWithUnderscoreAndCapitalLetter
}
TEST_F(ProductConfigHelperTests, givenProductAcronymWhenAdjustDeviceNameThenNothingIsChangedAndSameStringIsPreserved) {
for (const auto &product : AOT::productConfigAcronyms) {
for (const auto &product : AOT::deviceAcronyms) {
std::string acronymCopy = product.first;
ProductConfigHelper::adjustDeviceName(acronymCopy);
EXPECT_STREQ(acronymCopy.c_str(), product.first.c_str());
@@ -111,7 +110,7 @@ TEST_F(ProductConfigHelperTests, givenFamilyAcronymWhenAdjustDeviceNameThenNothi
}
TEST_F(ProductConfigHelperTests, givenProductAcronymWhenRemoveDashesFromTheNameThenStillCorrectValueIsReturned) {
for (const auto &[acronym, value] : AOT::productConfigAcronyms) {
for (const auto &[acronym, value] : AOT::deviceAcronyms) {
std::string acronymCopy = acronym;
auto findDash = acronymCopy.find("-");
@@ -174,7 +173,7 @@ TEST_F(ProductConfigHelperTests, givenAcronymWithoutDashesWhenSearchMatchInSampl
}
TEST_F(ProductConfigHelperTests, givenProductConfigValueWhenParseVersionThenCorrectValueIsReturned) {
for (const auto &configMap : AOT::productConfigAcronyms) {
for (const auto &configMap : AOT::deviceAcronyms) {
auto version = ProductConfigHelper::parseMajorMinorRevisionValue(configMap.second);
auto productConfig = ProductConfigHelper::getProductConfigForVersionValue(version);
EXPECT_EQ(productConfig, configMap.second);
@@ -234,18 +233,6 @@ TEST_F(ProductConfigHelperTests, GivenDifferentHwInfoInDeviceAotInfosWhenCompari
ASSERT_TRUE(lhs == rhs);
}
struct AotDeviceInfoTests : public ::testing::Test {
AotDeviceInfoTests() {
productConfigHelper = std::make_unique<ProductConfigHelper>();
}
std::unique_ptr<ProductConfigHelper> productConfigHelper;
};
template <typename EqComparableT>
auto findAcronym(const EqComparableT &lhs) {
return [&lhs](const auto &rhs) { return lhs == rhs; };
}
TEST_F(AotDeviceInfoTests, givenProductOrAotConfigWhenParseMajorMinorRevisionValueThenCorrectStringIsReturned) {
auto &enabledDeviceConfigs = productConfigHelper->getDeviceAotInfo();
if (enabledDeviceConfigs.empty()) {
@@ -505,3 +492,11 @@ TEST_F(AotDeviceInfoTests, givenUnknownIsaWhenGetDeviceAotInfoThenFalseIsReturne
EXPECT_FALSE(productConfigHelper->getDeviceAotInfoForProductConfig(AOT::UNKNOWN_ISA, aotInfo));
EXPECT_TRUE(aotInfo == emptyInfo);
}
TEST_F(AotDeviceInfoTests, givenProductConfigHelperWhenGetDeviceAcronymsThenCorrectResultsAreReturned) {
auto acronyms = productConfigHelper->getDeviceAcronyms();
for (const auto &acronym : AOT::deviceAcronyms) {
EXPECT_TRUE(std::any_of(acronyms.begin(), acronyms.end(), findAcronym(acronym.first)));
}
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/product_config_helper.h"
#include "shared/test/common/test_macros/test.h"
using ProductConfigHelperTests = ::testing::Test;
struct AotDeviceInfoTests : public ProductConfigHelperTests {
AotDeviceInfoTests() {
productConfigHelper = std::make_unique<ProductConfigHelper>();
}
std::unique_ptr<ProductConfigHelper> productConfigHelper;
};
template <typename EqComparableT>
auto findAcronym(const EqComparableT &lhs) {
return [&lhs](const auto &rhs) { return lhs == rhs; };
}