[Lldb-commits] [lldb] r340589 - Add more pre-run asserts for the DirCompletionAbsolute test

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 23 16:21:52 PDT 2018


Author: teemperor
Date: Thu Aug 23 16:21:52 2018
New Revision: 340589

URL: http://llvm.org/viewvc/llvm-project?rev=340589&view=rev
Log:
Add more pre-run asserts for the DirCompletionAbsolute test

Summary:
The DirCompletionAbsolute is still randomly failing on the nodes even after D50722, so this patch adds more asserts
that verify certain properties on which the actual completion implementation relies on.

The first assert checks that the directory we complete on actually exists. If the directory doesn't exist on the
next CI failure, this assert should catch it and we know that the 0 matches come from a missing base directory.

The second assert is just checking that we are below the PATH_MAX limit that the completion checks against.
This check could randomly fail if the temporary directories we generate are sometimes longer than PATH_MAX,
and the assert can tell us that this is the reason we failed (instead of the mysterious '0 matches').

(As a sidenote: We shouldn't be checking against PATH_MAX anyway in the code (as this is just wrong). Also
the disk completion API really needs a better error mechanism than returning 0 on both error or no-results.)

Reviewers: aprantl, friss

Reviewed By: aprantl

Subscribers: abidh

Differential Revision: https://reviews.llvm.org/D51111

Modified:
    lldb/trunk/unittests/Interpreter/TestCompletion.cpp

Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=340589&r1=340588&r2=340589&view=diff
==============================================================================
--- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original)
+++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Thu Aug 23 16:21:52 2018
@@ -163,6 +163,9 @@ TEST_F(CompletionTest, DirCompletionAbso
 
   // When a directory is specified that doesn't end in a slash, it searches
   // for that directory, not items under it.
+  // Sanity check that the path we complete on exists and isn't too long.
+  ASSERT_TRUE(llvm::sys::fs::exists(BaseDir));
+  ASSERT_LE(BaseDir.size(), static_cast<size_t>(PATH_MAX));
   size_t Count =
       CommandCompletions::DiskDirectories(BaseDir, Results, Resolver);
   ASSERT_EQ(1u, Count);




More information about the lldb-commits mailing list