mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Support for non-Latin characters in application path for AIL
Signed-off-by: Konstanty Misiak <konstanty.misiak@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
44649faa0f
commit
cd0c97bdc5
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -18,23 +18,22 @@ bool AILConfiguration::initProcessExecutableName() {
|
||||
auto status = SysCalls::getModuleFileName(nullptr, processFilenameW, MAX_PATH);
|
||||
|
||||
if (status != 0) {
|
||||
std::wcstombs(processFilename, processFilenameW, MAX_PATH);
|
||||
std::wstring_view pathView(processFilenameW);
|
||||
|
||||
auto lastPosition = pathView.find_last_of(L"\\");
|
||||
|
||||
pathView.remove_prefix(lastPosition + 1u);
|
||||
|
||||
lastPosition = pathView.find(L".exe");
|
||||
|
||||
if (lastPosition != std::wstring_view::npos) {
|
||||
pathView.remove_suffix(pathView.size() - lastPosition);
|
||||
}
|
||||
|
||||
std::wcstombs(processFilename, pathView.data(), pathView.size());
|
||||
processName = processFilename;
|
||||
}
|
||||
|
||||
std::string_view pathView(processFilename);
|
||||
|
||||
auto lastPosition = pathView.find_last_of("\\");
|
||||
|
||||
pathView.remove_prefix(lastPosition + 1u);
|
||||
|
||||
lastPosition = pathView.find(".exe");
|
||||
|
||||
if (lastPosition != std::string_view::npos) {
|
||||
pathView.remove_suffix(pathView.size() - lastPosition);
|
||||
}
|
||||
|
||||
processName = pathView;
|
||||
|
||||
return status;
|
||||
}
|
||||
} // namespace NEO
|
||||
} // namespace NEO
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
using AILTests = ::testing::Test;
|
||||
namespace SysCalls {
|
||||
extern const wchar_t *currentLibraryPath;
|
||||
@ -49,4 +50,19 @@ HWTEST2_F(AILTests, givenValidApplicationPathWithoutLongNameWhenAILinitProcessEx
|
||||
|
||||
EXPECT_EQ("application", ailTemp.processName);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
HWTEST2_F(AILTests, givenApplicationPathWithNonLatinCharactersWhenAILinitProcessExecutableNameThenProperProcessNameIsReturned, IsAtLeastGen12lp) {
|
||||
VariableBackup<const wchar_t *> applicationPathBackup(&SysCalls::currentLibraryPath);
|
||||
applicationPathBackup = L"C\\\u4E20\u4E24\\application";
|
||||
|
||||
VariableBackup<AILConfiguration *> ailConfigurationBackup(&ailConfigurationTable[productFamily]);
|
||||
|
||||
AILMock<productFamily> ailTemp;
|
||||
ailConfigurationTable[productFamily] = &ailTemp;
|
||||
|
||||
EXPECT_EQ(ailTemp.initProcessExecutableName(), true);
|
||||
|
||||
EXPECT_EQ("application", ailTemp.processName);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
Reference in New Issue
Block a user