Skip to content

Commit 6025fee

Browse files
authored
Merge pull request #1868 from kbenzie/benie/fix-win-mock
Fix mock on Windows, add logging of adapter load/unload
2 parents c836ff6 + ff47a03 commit 6025fee

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

source/adapters/mock/ur_mock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ur_result_t mock_urPlatformGetInfo(void *pParams) {
2929
}
3030

3131
if (*params.ppropName == UR_PLATFORM_INFO_NAME) {
32-
const char mock_platform_name[] = "UR_PLATFORM_MOCK";
32+
const char mock_platform_name[] = "Mock Platform";
3333
if (*params.ppPropSizeRet) {
3434
**params.ppPropSizeRet = sizeof(mock_platform_name);
3535
}

source/common/windows/ur_lib_loader.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ void LibLoader::freeAdapterLibrary(HMODULE handle) {
1919
logger::error(
2020
"Failed to unload the library with the handle at address {}",
2121
handle);
22+
} else {
23+
logger::info("unloaded adapter 0x{}", handle);
2224
}
2325
}
2426
}
2527

2628
std::unique_ptr<HMODULE, LibLoader::lib_dtor>
2729
LibLoader::loadAdapterLibrary(const char *name) {
28-
return std::unique_ptr<HMODULE, LibLoader::lib_dtor>(
30+
auto handle = std::unique_ptr<HMODULE, LibLoader::lib_dtor>(
2931
LoadLibraryExA(name, nullptr, 0));
32+
logger::info("loaded adapter 0x{} ({})", handle, name);
33+
return handle;
3034
}
3135

3236
void *LibLoader::getFunctionPtr(HMODULE handle, const char *func_name) {

source/loader/ur_adapter_registry.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,9 @@ class AdapterRegistry {
188188
adaptersLoadPaths.clear();
189189

190190
std::vector<fs::path> loadPaths;
191-
auto adapterNamePathOpt = getAdapterNameAsPath(mockAdapterName);
191+
auto adapterNamePath = fs::path{mockAdapterName};
192192
auto loaderLibPathOpt = getLoaderLibPath();
193-
if (adapterNamePathOpt.has_value() && loaderLibPathOpt.has_value()) {
194-
const auto &adapterNamePath = adapterNamePathOpt.value();
193+
if (loaderLibPathOpt.has_value()) {
195194
const auto &loaderLibPath = loaderLibPathOpt.value();
196195
loadPaths.emplace_back(loaderLibPath / adapterNamePath);
197196
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<TEST>[INFO]: urLoaderInit succeeded.
22
<TEST>[INFO]: urPlatformGet found 1 platforms
3-
<TEST>[INFO]: Found UR_PLATFORM_MOCK
3+
<TEST>[INFO]: Found Mock Platform

0 commit comments

Comments
 (0)