feature: refactor and rewrite setErrorDescription

Related-To: NEO-8379

Signed-off-by: Winston Zhang <winston.zhang@intel.com>
This commit is contained in:
Winston Zhang
2024-08-20 00:14:56 +00:00
committed by Compute-Runtime-Automation
parent 60711a169e
commit 0590b34cfa
13 changed files with 172 additions and 82 deletions

View File

@@ -324,7 +324,9 @@ static_assert(sizeof(ExecutionEnvironment) == sizeof(std::unique_ptr<HardwareInf
(is64bit ? 18 : 14) +
sizeof(std::mutex) +
sizeof(std::unordered_map<uint32_t, std::tuple<uint32_t, uint32_t, uint32_t>>) +
sizeof(std::vector<std::tuple<std::string, uint32_t>>),
sizeof(std::vector<std::tuple<std::string, uint32_t>>) +
sizeof(std::unordered_map<std::thread::id, std::string>) +
sizeof(std::mutex),
"New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct");
TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDestroyedThenDeleteSequenceIsSpecified) {
@@ -618,6 +620,63 @@ TEST(ExecutionEnvironmentDeviceHierarchy, givenExecutionEnvironmentWithCombinedD
EXPECT_FALSE(executionEnvironment.isExposingSubDevicesAsDevices());
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenSetErrorDescriptionIsCalledThenGetErrorDescriptionGetsStringCorrectly) {
std::string errorString = "we manually created error";
std::string errorString2 = "here's the next string to pass with arguments: ";
MockExecutionEnvironment executionEnvironment;
executionEnvironment.setErrorDescription(std::string(errorString));
const char *pStr = nullptr;
executionEnvironment.getErrorDescription(&pStr);
EXPECT_EQ(0, strcmp(errorString.c_str(), pStr));
int result = [](MockExecutionEnvironment *exeEnv, const std::string &str) {
int res = exeEnv->setErrorDescription(std::string(str));
return res;
}(&executionEnvironment, errorString2);
EXPECT_NE(0, result);
executionEnvironment.getErrorDescription(&pStr);
std::string expectedString = errorString2;
printf("the received string is: \"%s\"\n", pStr);
printf("the expected string is: \"%s\"\n", expectedString.c_str());
EXPECT_EQ(0, strcmp(expectedString.c_str(), pStr));
}
TEST(ExecutionEnvironment, givenValidExecutionEnvironmentWhenClearErrorDescriptionIsCalledThenEmptyStringIsReturned) {
std::string errorString = "error string";
std::string emptyString = "";
const char *pStr = nullptr;
MockExecutionEnvironment executionEnvironment;
int result = executionEnvironment.clearErrorDescription();
EXPECT_EQ(0, result);
executionEnvironment.getErrorDescription(&pStr);
EXPECT_EQ(0, strcmp(emptyString.c_str(), pStr));
executionEnvironment.setErrorDescription(errorString);
executionEnvironment.getErrorDescription(&pStr);
EXPECT_EQ(0, strcmp(errorString.c_str(), pStr));
EXPECT_EQ(0, result);
result = executionEnvironment.clearErrorDescription();
EXPECT_EQ(0, result);
executionEnvironment.getErrorDescription(&pStr);
EXPECT_EQ(0, strcmp(emptyString.c_str(), pStr));
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenGetErrorDescriptionIsCalledThenEmptyStringIsReturned) {
std::string errorString = "";
MockExecutionEnvironment executionEnvironment;
const char *pStr = nullptr;
executionEnvironment.getErrorDescription(&pStr);
EXPECT_EQ(0, strcmp(errorString.c_str(), pStr));
executionEnvironment.setErrorDescription(errorString);
executionEnvironment.getErrorDescription(&pStr);
EXPECT_EQ(0, strcmp(errorString.c_str(), pStr));
}
void ExecutionEnvironmentSortTests::SetUp() {
executionEnvironment.prepareRootDeviceEnvironments(numRootDevices);
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < numRootDevices; rootDeviceIndex++) {