Files
TheRock/rocm-libraries/projects/hipdnn/tests/frontend/IntegrationTestPluginInfrastructure.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

97 lines
2.5 KiB
C++

// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <test_plugins/TestPluginCommon.hpp>
#include <test_plugins/TestPluginConstants.hpp>
#include <filesystem>
#include <string>
#include <utility>
#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
#endif
namespace
{
class ScopedTempFile
{
public:
explicit ScopedTempFile(std::filesystem::path path)
: _path(std::move(path))
{
std::filesystem::remove(_path);
}
~ScopedTempFile()
{
std::error_code ignored;
std::filesystem::remove(_path, ignored);
}
ScopedTempFile(const ScopedTempFile&) = delete;
ScopedTempFile& operator=(const ScopedTempFile&) = delete;
const std::filesystem::path& path() const
{
return _path;
}
std::string string() const
{
return _path.string();
}
private:
std::filesystem::path _path;
};
int currentProcessId()
{
#ifdef _WIN32
return _getpid();
#else
return ::getpid();
#endif
}
} // namespace
TEST(IntegrationPluginInfrastructure, NoLoadMissThenScopedOwnerHitAndUnload)
{
const auto sourcePath = test_plugin_internal::resolvePluginPathRelativeToBackend(
hipdnn_tests::plugin_constants::testSecondOverridePluginPath());
const auto probePath
= std::filesystem::temp_directory_path()
/ ("hipdnn_second_override_noload_probe_" + std::to_string(currentProcessId())
+ sourcePath.extension().string());
const ScopedTempFile probeFile(probePath);
std::filesystem::copy_file(
sourcePath, probeFile.path(), std::filesystem::copy_options::overwrite_existing);
const auto pluginPath = probeFile.string();
constexpr const char* SUFFIX = "SecondOverride";
ASSERT_EQ(getLastCallRecordIfLoaded(pluginPath, SUFFIX), nullptr)
<< "RTLD_NOLOAD lookup must not load a plugin on miss.";
{
const ScopedTestPluginLibrary owner(pluginPath);
ASSERT_NE(getLastCallRecordIfLoaded(pluginPath, SUFFIX), nullptr)
<< "RTLD_NOLOAD lookup should resolve while a real owner pins the plugin.";
resetLastCallRecord(owner, SUFFIX);
const auto* record = getLastCallRecord(owner, SUFFIX);
ASSERT_NE(record, nullptr);
EXPECT_EQ(record->whichEntry, TestPluginExecuteEntry::NONE);
}
EXPECT_EQ(getLastCallRecordIfLoaded(pluginPath, SUFFIX), nullptr)
<< "The temporary RTLD_NOLOAD handle must not keep the plugin loaded after owner teardown.";
}