diff options
author | Petr Pavlu <petr.pavlu@arm.com> | 2018-04-21 14:35:18 +0000 |
---|---|---|
committer | Petr Pavlu <petr.pavlu@arm.com> | 2018-04-21 14:35:18 +0000 |
commit | b25187adfbe3213c99048d58a94f242f95db7eac (patch) | |
tree | 9375f2237a5b3532fd03b10619e7ab7fb429e586 /clang/unittests/libclang/LibclangTest.cpp | |
parent | d73bd154d9f2d94dafb0eed4680c301573350ec2 (diff) | |
download | llvm-b25187adfbe3213c99048d58a94f242f95db7eac.zip llvm-b25187adfbe3213c99048d58a94f242f95db7eac.tar.gz llvm-b25187adfbe3213c99048d58a94f242f95db7eac.tar.bz2 |
[libclang] Fix LibclangReparseTest.FileName when TMPDIR is set to a symlink
Fix testing of clang_File_tryGetRealPathName() in
LibclangReparseTest.FileName when executing in an environment which has
TMPDIR set to a symbolic link that points to an actual directory. The
test would fail because the name returned by
clang_File_tryGetRealPathName() has the symlink resolved but the test
compared it to the original filename of a temporary file.
The patch addresses the problem by checking only that the value returned
by clang_File_tryGetRealPathName() ends with "main.cpp".
Additionally, the patch makes the previous assertion in the test that
checks result of clang_getFileName() stricter. It newly verifies that
the name returned by the function is exactly same as what was given to
clang_parseTranslationUnit()/clang_getFile().
Differential Revision: https://reviews.llvm.org/D45807
llvm-svn: 330507
Diffstat (limited to 'clang/unittests/libclang/LibclangTest.cpp')
-rw-r--r-- | clang/unittests/libclang/LibclangTest.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/unittests/libclang/LibclangTest.cpp b/clang/unittests/libclang/LibclangTest.cpp index 262ed26..c727b93 100644 --- a/clang/unittests/libclang/LibclangTest.cpp +++ b/clang/unittests/libclang/LibclangTest.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "clang-c/Index.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" @@ -490,11 +491,11 @@ TEST_F(LibclangReparseTest, FileName) { CXFile cxf = clang_getFile(ClangTU, CppName.c_str()); CXString cxname = clang_getFileName(cxf); - ASSERT_TRUE(strstr(clang_getCString(cxname), CppName.c_str())); + ASSERT_STREQ(clang_getCString(cxname), CppName.c_str()); clang_disposeString(cxname); cxname = clang_File_tryGetRealPathName(cxf); - ASSERT_TRUE(strstr(clang_getCString(cxname), CppName.c_str())); + ASSERT_TRUE(llvm::StringRef(clang_getCString(cxname)).endswith("main.cpp")); clang_disposeString(cxname); } |