diff options
author | Adrian Prantl <aprantl@apple.com> | 2018-12-06 00:43:55 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2018-12-06 00:43:55 +0000 |
commit | 7b8a03751c24eb92012e4a99070c7be5b1a0b65d (patch) | |
tree | 933b352308078daa7fa25362f2832d7e0a5400e2 | |
parent | 3cd70b385df8d2f9b4de6165f17b4a07649d2f07 (diff) | |
download | bcm5719-llvm-7b8a03751c24eb92012e4a99070c7be5b1a0b65d.tar.gz bcm5719-llvm-7b8a03751c24eb92012e4a99070c7be5b1a0b65d.zip |
Add a unit test for ArchSpec matching to document how it behaves (and test it).
llvm-svn: 348440
-rw-r--r-- | lldb/source/Utility/ArchSpec.cpp | 4 | ||||
-rw-r--r-- | lldb/unittests/Utility/ArchSpecTest.cpp | 50 |
2 files changed, 52 insertions, 2 deletions
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp index 761d6068ff6..be51921de50 100644 --- a/lldb/source/Utility/ArchSpec.cpp +++ b/lldb/source/Utility/ArchSpec.cpp @@ -1019,7 +1019,7 @@ bool ArchSpec::IsCompatibleMatch(const ArchSpec &rhs) const { return IsEqualTo(rhs, false); } -static bool isCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, +static bool IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, llvm::Triple::EnvironmentType rhs) { if (lhs == rhs) return true; @@ -1096,7 +1096,7 @@ bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const { const llvm::Triple::EnvironmentType rhs_triple_env = rhs_triple.getEnvironment(); - if (!isCompatibleEnvironment(lhs_triple_env, rhs_triple_env)) + if (!IsCompatibleEnvironment(lhs_triple_env, rhs_triple_env)) return false; return true; } diff --git a/lldb/unittests/Utility/ArchSpecTest.cpp b/lldb/unittests/Utility/ArchSpecTest.cpp index d7397cbec53..a84112ea289 100644 --- a/lldb/unittests/Utility/ArchSpecTest.cpp +++ b/lldb/unittests/Utility/ArchSpecTest.cpp @@ -171,3 +171,53 @@ TEST(ArchSpecTest, MergeFromMachOUnknown) { A.MergeFrom(B); ASSERT_EQ(A.GetCore(), ArchSpec::eCore_uknownMach64); } + +TEST(ArchSpecTest, Compatibility) { + { + ArchSpec A("x86_64-apple-macosx10.12"); + ArchSpec B("x86_64-apple-macosx10.12"); + ASSERT_TRUE(A.IsExactMatch(B)); + ASSERT_TRUE(A.IsCompatibleMatch(B)); + } + { + // The version information is auxiliary to support availablity but + // doesn't affect compatibility. + ArchSpec A("x86_64-apple-macosx10.11"); + ArchSpec B("x86_64-apple-macosx10.12"); + ASSERT_TRUE(A.IsExactMatch(B)); + ASSERT_TRUE(A.IsCompatibleMatch(B)); + } + { + ArchSpec A("x86_64-apple-macosx10.13"); + ArchSpec B("x86_64h-apple-macosx10.13"); + ASSERT_FALSE(A.IsExactMatch(B)); + ASSERT_TRUE(A.IsCompatibleMatch(B)); + } + { + ArchSpec A("x86_64-apple-macosx"); + ArchSpec B("x86_64-apple-ios-simulator"); + ASSERT_FALSE(A.IsExactMatch(B)); + ASSERT_FALSE(A.IsCompatibleMatch(B)); + } + { + ArchSpec A("x86_64-*-*"); + ArchSpec B("x86_64-apple-ios-simulator"); + ASSERT_FALSE(A.IsExactMatch(B)); + ASSERT_FALSE(A.IsCompatibleMatch(B)); + } + { + ArchSpec A("arm64-*-*"); + ArchSpec B("arm64-apple-ios"); + ASSERT_FALSE(A.IsExactMatch(B)); + // FIXME: This looks unintuitive and we should investigate whether + // thi is the desired behavior. + ASSERT_FALSE(A.IsCompatibleMatch(B)); + } + { + ArchSpec A("x86_64-*-*"); + ArchSpec B("x86_64-apple-ios-simulator"); + ASSERT_FALSE(A.IsExactMatch(B)); + // FIXME: See above, though the extra environment complicates things. + ASSERT_FALSE(A.IsCompatibleMatch(B)); + } +} |