#include "lldb/Host/HostInfo.h"
#include "TestingSupport/SubsystemRAII.h"
#include "TestingSupport/TestUtilities.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/lldb-defines.h"
#include "llvm/TargetParser/Host.h"
#include "gtest/gtest.h"
usingnamespacelldb_private;
usingnamespacellvm;
namespace {
class HostInfoTest : public ::testing::Test { … };
}
TEST_F(HostInfoTest, GetAugmentedArchSpec) { … }
TEST_F(HostInfoTest, GetHostname) { … }
#if defined(__APPLE__)
TEST_F(HostInfoTest, GetXcodeSDK) {
auto get_sdk = [](std::string sdk, bool error = false) -> llvm::StringRef {
auto sdk_path_or_err =
HostInfo::GetSDKRoot(HostInfo::SDKOptions{XcodeSDK(std::move(sdk))});
if (!error) {
EXPECT_TRUE((bool)sdk_path_or_err);
return *sdk_path_or_err;
}
EXPECT_FALSE((bool)sdk_path_or_err);
llvm::consumeError(sdk_path_or_err.takeError());
return {};
};
EXPECT_FALSE(get_sdk("MacOSX.sdk").empty());
EXPECT_FALSE(get_sdk("MacOSX9999.sdk").empty());
EXPECT_TRUE(get_sdk("CeciNestPasUnOS.sdk", true).empty());
}
TEST_F(HostInfoTest, FindSDKTool) {
auto find_tool = [](std::string sdk, llvm::StringRef tool,
bool error = false) -> llvm::StringRef {
auto sdk_path_or_err =
HostInfo::FindSDKTool(XcodeSDK(std::move(sdk)), tool);
if (!error) {
EXPECT_TRUE((bool)sdk_path_or_err);
return *sdk_path_or_err;
}
EXPECT_FALSE((bool)sdk_path_or_err);
llvm::consumeError(sdk_path_or_err.takeError());
return {};
};
EXPECT_FALSE(find_tool("MacOSX.sdk", "clang").empty());
EXPECT_TRUE(find_tool("MacOSX.sdk", "CeciNestPasUnOutil").empty());
}
#endif
TEST(HostInfoTestInitialization, InitTwice) { … }