Test leaks if we run
tools/lldb/unittests/Host/HostTests without --gtest_filter
Reviewed By: teemperor
Differential Revision: https://reviews.llvm.org/D104091
public:
static void Initialize(SharedLibraryDirectoryHelper *helper = nullptr);
+ static void Terminate();
static llvm::VersionTuple GetOSVersion();
static bool GetOSBuildString(std::string &s);
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, []() {
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());
+ }
+}