forked from OSchip/llvm-project
[lldb] Fix leak in test
Test leaks if we run tools/lldb/unittests/Host/HostTests without --gtest_filter Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D104091
This commit is contained in:
parent
bc104fdcec
commit
f3f904563e
|
@ -28,6 +28,7 @@ private:
|
|||
|
||||
public:
|
||||
static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr);
|
||||
static void Terminate();
|
||||
|
||||
static llvm::VersionTuple GetOSVersion();
|
||||
static bool GetOSBuildString(std::string &s);
|
||||
|
|
|
@ -41,6 +41,13 @@ void HostInfoLinux::Initialize(SharedLibraryDirectoryHelper *helper) {
|
|||
g_fields = new HostInfoLinuxFields();
|
||||
}
|
||||
|
||||
void HostInfoLinux::Terminate() {
|
||||
assert(g_fields && "Missing call to Initialize?");
|
||||
delete g_fields;
|
||||
g_fields = nullptr;
|
||||
HostInfoBase::Terminate();
|
||||
}
|
||||
|
||||
llvm::VersionTuple HostInfoLinux::GetOSVersion() {
|
||||
assert(g_fields && "Missing call to Initialize?");
|
||||
llvm::call_once(g_fields->m_os_version_once_flag, []() {
|
||||
|
|
|
@ -60,3 +60,16 @@ TEST_F(HostInfoTest, GetXcodeSDK) {
|
|||
EXPECT_TRUE(HostInfo::GetXcodeSDKPath(XcodeSDK("CeciNestPasUnOS.sdk")).empty());
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(HostInfoTestInitialization, InitTwice) {
|
||||
llvm::VersionTuple Version;
|
||||
{
|
||||
SubsystemRAII<FileSystem, HostInfo> subsystems;
|
||||
Version = HostInfo::GetOSVersion();
|
||||
}
|
||||
|
||||
{
|
||||
SubsystemRAII<FileSystem, HostInfo> subsystems;
|
||||
EXPECT_EQ(Version, HostInfo::GetOSVersion());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue