[Lldb-commits] [lldb] r324368 - Build each testcase variant in its own subdirectory and remove the srcdir lock file

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 6 10:22:52 PST 2018


Author: adrian
Date: Tue Feb  6 10:22:51 2018
New Revision: 324368

URL: http://llvm.org/viewvc/llvm-project?rev=324368&view=rev
Log:
Build each testcase variant in its own subdirectory and remove the srcdir lock file
This patch creates a <test>.dwarf, <test>.dwo, etc., build directory for each testcase variant.
Most importantly, this eliminates the need for the per-test lock file in the source directory.

Tests that are marked as NO_DEBUG_INFO_TESTCASE and build with
buildDefault() are built in a <test>.default build directory.

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

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
    lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
    lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
    lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
    lldb/trunk/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py
    lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py
    lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py
    lldb/trunk/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py Tue Feb  6 10:22:51 2018
@@ -23,10 +23,10 @@ class ListenToModuleLoadedEvents (TestBa
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
-        self.build()
 
     def test_receiving_breakpoint_added(self):
         """Test that we get breakpoint added events, waiting on event classes on the debugger"""
+        self.build()
 
         my_listener = lldb.SBListener("test_listener")
 

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py Tue Feb  6 10:22:51 2018
@@ -28,8 +28,6 @@ class CompDirSymLinkTestCase(TestBase):
         self.line = line_number(
             os.path.join(self.getSourceDir(), "main.cpp"),
             '// Set break point at this line.')
-        self.src_path = self.getBuildArtifact(_SRC_FILE)
-
 
     @skipIf(hostoslist=["windows"])
     def test_symlink_paths_set(self):
@@ -38,7 +36,8 @@ class CompDirSymLinkTestCase(TestBase):
         self.runCmd(
             "settings set %s %s" %
             (_COMP_DIR_SYM_LINK_PROP, pwd_symlink))
-        lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line)
+        src_path = self.getBuildArtifact(_SRC_FILE)
+        lldbutil.run_break_set_by_file_and_line(self, src_path, self.line)
 
     @skipIf(hostoslist=no_match(["linux"]))
     def test_symlink_paths_set_procselfcwd(self):
@@ -48,21 +47,24 @@ class CompDirSymLinkTestCase(TestBase):
         self.runCmd(
             "settings set %s %s" %
             (_COMP_DIR_SYM_LINK_PROP, pwd_symlink))
-        lldbutil.run_break_set_by_file_and_line(self, self.src_path, self.line)
+        src_path = self.getBuildArtifact(_SRC_FILE)
+        lldbutil.run_break_set_by_file_and_line(self, src_path, self.line)
 
     @skipIf(hostoslist=["windows"])
     def test_symlink_paths_unset(self):
         pwd_symlink = self.create_src_symlink()
         self.doBuild(pwd_symlink)
         self.runCmd('settings clear ' + _COMP_DIR_SYM_LINK_PROP)
+        src_path = self.getBuildArtifact(_SRC_FILE)
         self.assertRaises(
             AssertionError,
             lldbutil.run_break_set_by_file_and_line,
             self,
-            self.src_path,
+            src_path,
             self.line)
 
     def create_src_symlink(self):
+        self.makeBuildDir()
         pwd_symlink = self.getBuildArtifact('pwd_symlink')
         if os.path.exists(pwd_symlink):
             os.unlink(pwd_symlink)

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py Tue Feb  6 10:22:51 2018
@@ -22,13 +22,18 @@ class LoadUnloadTestCase(TestBase):
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
-        lldbutil.mkdir_p(self.getBuildArtifact("hidden"))
+        self.setup_test()
+        # Invoke the default build rule.
+        self.build()
         # Find the line number to break for main.cpp.
         self.line = line_number(
             'main.cpp',
             '// Set break point at this line for test_lldb_process_load_and_unload_commands().')
         self.line_d_function = line_number(
             'd.cpp', '// Find this line number within d_dunction().')
+
+    def setup_test(self):
+        lldbutil.mkdir_p(self.getBuildArtifact("hidden"))
         if not self.platformIsDarwin():
             if not lldb.remote_platform and "LD_LIBRARY_PATH" in os.environ:
                 self.runCmd(
@@ -94,10 +99,6 @@ class LoadUnloadTestCase(TestBase):
     @skipIfWindows  # Windows doesn't have dlopen and friends, dynamic libraries work differently
     def test_modules_search_paths(self):
         """Test target modules list after loading a different copy of the library libd.dylib, and verifies that it works with 'target modules search-paths add'."""
-
-        # Invoke the default build rule.
-        self.build()
-
         if self.platformIsDarwin():
             dylibName = 'libloadunload_d.dylib'
         else:
@@ -157,9 +158,6 @@ class LoadUnloadTestCase(TestBase):
     @skipIfWindows  # Windows doesn't have dlopen and friends, dynamic libraries work differently
     def test_dyld_library_path(self):
         """Test (DY)LD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else."""
-
-        # Invoke the default build rule.
-        self.build()
         self.copy_shlibs_to_remote(hidden_dir=True)
 
         exe = self.getBuildArtifact("a.out")
@@ -222,9 +220,6 @@ class LoadUnloadTestCase(TestBase):
     @skipIfWindows  # Windows doesn't have dlopen and friends, dynamic libraries work differently
     def test_lldb_process_load_and_unload_commands(self):
         """Test that lldb process load/unload command work correctly."""
-
-        # Invoke the default build rule.
-        self.build()
         self.copy_shlibs_to_remote()
 
         exe = self.getBuildArtifact("a.out")
@@ -296,9 +291,6 @@ class LoadUnloadTestCase(TestBase):
     @skipIfFreeBSD  # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
     def test_load_unload(self):
         """Test breakpoint by name works correctly with dlopen'ing."""
-
-        # Invoke the default build rule.
-        self.build()
         self.copy_shlibs_to_remote()
 
         exe = self.getBuildArtifact("a.out")
@@ -339,9 +331,6 @@ class LoadUnloadTestCase(TestBase):
     @skipIfWindows  # Windows doesn't have dlopen and friends, dynamic libraries work differently
     def test_step_over_load(self):
         """Test stepping over code that loads a shared library works correctly."""
-
-        # Invoke the default build rule.
-        self.build()
         self.copy_shlibs_to_remote()
 
         exe = self.getBuildArtifact("a.out")
@@ -374,8 +363,6 @@ class LoadUnloadTestCase(TestBase):
     @skipIfWindows  # Windows doesn't have dlopen and friends, dynamic libraries work differently
     def test_static_init_during_load(self):
         """Test that we can set breakpoints correctly in static initializers"""
-
-        self.build()
         self.copy_shlibs_to_remote()
 
         exe = self.getBuildArtifact("a.out")

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py Tue Feb  6 10:22:51 2018
@@ -22,8 +22,10 @@ class TestValueOfVectorVariableTestCase(
         bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
     def test_value_of_vector_variable_using_watchpoint_set(self):
         """Test verify displayed value of vector variable."""
-        self.build(dictionary=self.d)
-        self.setTearDownCleanup(dictionary=self.d)
+        exe = self.getBuildArtifact("a.out")
+        d = {'C_SOURCES': self.source, 'EXE': exe}
+        self.build(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
         self.value_of_vector_variable_with_watchpoint_set()
 
     def setUp(self):
@@ -31,8 +33,6 @@ class TestValueOfVectorVariableTestCase(
         TestBase.setUp(self)
         # Our simple source filename.
         self.source = 'main.c'
-        self.exe_name = self.getBuildArtifact("a.out")
-        self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
 
     def value_of_vector_variable_with_watchpoint_set(self):
         """Test verify displayed value of vector variable"""

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py Tue Feb  6 10:22:51 2018
@@ -92,9 +92,9 @@ class InlineTest(TestBase):
             # The test was skipped altogether.
             return ""
         elif self.using_dsym:
-            return "-N dwarf %s" % (self.mydir)
+            return "-N dwarf " + self.mydir
         else:
-            return "-N dsym %s" % (self.mydir)
+            return "-N dsym " + self.mydir
 
     def BuildMakefile(self):
         self.makeBuildDir()

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Tue Feb  6 10:22:51 2018
@@ -523,11 +523,14 @@ class Base(unittest2.TestCase):
 
     @staticmethod
     def compute_mydir(test_file):
-        '''Subclasses should call this function to correctly calculate the required "mydir" attribute as follows:
+        '''Subclasses should call this function to correctly calculate the
+           required "mydir" attribute as follows:
 
-            mydir = TestBase.compute_mydir(__file__)'''
-        test_dir = os.path.dirname(test_file)
-        return test_dir[len(os.environ["LLDB_TEST"]) + 1:]
+            mydir = TestBase.compute_mydir(__file__)
+        '''
+        # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
+        rel_prefix = test_file[len(os.environ["LLDB_TEST"]) + 1:]
+        return os.path.dirname(rel_prefix)
 
     def TraceOn(self):
         """Returns True if we are in trace mode (tracing detailed test execution)."""
@@ -549,32 +552,11 @@ class Base(unittest2.TestCase):
         # Change current working directory if ${LLDB_TEST} is defined.
         # See also dotest.py which sets up ${LLDB_TEST}.
         if ("LLDB_TEST" in os.environ):
-            full_dir = os.path.join(os.environ["LLDB_TEST"], cls.mydir)
+            full_dir = os.path.join(os.environ["LLDB_TEST"],
+                                    cls.mydir)
             if traceAlways:
                 print("Change dir to:", full_dir, file=sys.stderr)
-            os.chdir(os.path.join(os.environ["LLDB_TEST"], cls.mydir))
-
-        # TODO: Obsolete this by creating one working dir per configuration.
-        if debug_confirm_directory_exclusivity:
-            import lock
-            cls.dir_lock = lock.Lock(os.path.join(full_dir, ".dirlock"))
-            try:
-                cls.dir_lock.try_acquire()
-                # write the class that owns the lock into the lock file
-                cls.dir_lock.handle.write(cls.__name__)
-            except IOError as ioerror:
-                # nothing else should have this directory lock
-                # wait here until we get a lock
-                cls.dir_lock.acquire()
-                # read the previous owner from the lock file
-                lock_id = cls.dir_lock.handle.read()
-                print(
-                    "LOCK ERROR: {} wants to lock '{}' but it is already locked by '{}'".format(
-                        cls.__name__,
-                        full_dir,
-                        lock_id),
-                    file=sys.stderr)
-                raise ioerror
+            os.chdir(full_dir)
 
         # Set platform context.
         cls.platformContext = lldbplatformutil.createPlatformContext()
@@ -725,14 +707,17 @@ class Base(unittest2.TestCase):
 
     def getBuildDir(self):
         """Return the full path to the current test."""
-        return os.path.join(os.environ["LLDB_BUILD"], self.mydir)
+        variant = self.getDebugInfo()
+        if variant is None:
+            variant = 'default'
+        return os.path.join(os.environ["LLDB_BUILD"], self.mydir,
+                            self.testMethodName)
     
      
     def makeBuildDir(self):
         """Create the test-specific working directory."""
         # See also dotest.py which sets up ${LLDB_BUILD}.
-        try: os.makedirs(self.getBuildDir())
-        except: pass
+        lldbutil.mkdir_p(self.getBuildDir())
  
     def getBuildArtifact(self, name="a.out"):
         """Return absolute path to an artifact in the test's build directory."""
@@ -1516,18 +1501,17 @@ class Base(unittest2.TestCase):
             architecture=None,
             compiler=None,
             dictionary=None,
-            clean=True,
-            testdir=None):
+            clean=True):
         """Platform specific way to build the default binaries."""
-        if not testdir:
-            testdir = self.mydir
+        testdir = self.mydir
+        testname = self.testMethodName
         if self.getDebugInfo():
             raise Exception("buildDefault tests must set NO_DEBUG_INFO_TESTCASE")
         module = builder_module()
         self.makeBuildDir()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildDefault(self, architecture, compiler,
-                                   dictionary, clean, testdir):
+                                   dictionary, clean, testdir, testname):
             raise Exception("Don't know how to build default binary")
 
     def buildDsym(
@@ -1535,18 +1519,17 @@ class Base(unittest2.TestCase):
             architecture=None,
             compiler=None,
             dictionary=None,
-            clean=True,
-            testdir=None):
+            clean=True):
         """Platform specific way to build binaries with dsym info."""
-        if not testdir:
-            testdir = self.mydir
+        testdir = self.mydir
+        testname = self.testMethodName
         if self.getDebugInfo() != "dsym":
             raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault")
 
         module = builder_module()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildDsym(self, architecture, compiler,
-                                dictionary, clean, testdir):
+                                dictionary, clean, testdir, testname):
             raise Exception("Don't know how to build binary with dsym")
 
     def buildDwarf(
@@ -1554,18 +1537,17 @@ class Base(unittest2.TestCase):
             architecture=None,
             compiler=None,
             dictionary=None,
-            clean=True,
-            testdir=None):
+            clean=True):
         """Platform specific way to build binaries with dwarf maps."""
-        if not testdir:
-            testdir = self.mydir
+        testdir = self.mydir
+        testname = self.testMethodName
         if self.getDebugInfo() != "dwarf":
             raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault")
 
         module = builder_module()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildDwarf(self, architecture, compiler,
-                                   dictionary, clean, testdir):
+                                   dictionary, clean, testdir, testname):
             raise Exception("Don't know how to build binary with dwarf")
 
     def buildDwo(
@@ -1573,18 +1555,17 @@ class Base(unittest2.TestCase):
             architecture=None,
             compiler=None,
             dictionary=None,
-            clean=True,
-            testdir=None):
+            clean=True):
         """Platform specific way to build binaries with dwarf maps."""
-        if not testdir:
-            testdir = self.mydir
+        testdir = self.mydir
+        testname = self.testMethodName
         if self.getDebugInfo() != "dwo":
             raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault")
 
         module = builder_module()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildDwo(self, architecture, compiler,
-                                   dictionary, clean, testdir):
+                                   dictionary, clean, testdir, testname):
             raise Exception("Don't know how to build binary with dwo")
 
     def buildGModules(
@@ -1592,18 +1573,17 @@ class Base(unittest2.TestCase):
             architecture=None,
             compiler=None,
             dictionary=None,
-            clean=True,
-            testdir=None):
+            clean=True):
         """Platform specific way to build binaries with gmodules info."""
-        if not testdir:
-            testdir = self.mydir
+        testdir = self.mydir
+        testname = self.testMethodName
         if self.getDebugInfo() != "gmodules":
             raise Exception("NO_DEBUG_INFO_TESTCASE must build with buildDefault")
 
         module = builder_module()
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if not module.buildGModules(self, architecture, compiler,
-                                   dictionary, clean, testdir):
+                                    dictionary, clean, testdir, testname):
             raise Exception("Don't know how to build binary with gmodules")
 
     def buildGo(self):
@@ -1778,6 +1758,7 @@ class LLDBTestCaseFactory(type):
                 supported_categories = [
                     x for x in categories if test_categories.is_supported_on_platform(
                         x, target_platform, configuration.compiler)]
+                
                 if "dsym" in supported_categories:
                     @decorators.add_test_categories(["dsym"])
                     @wraps(attrvalue)
@@ -2322,19 +2303,17 @@ class TestBase(Base):
         dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
         if self.getDebugInfo() is None:
             return self.buildDefault(architecture, compiler, dictionary,
-                                     clean, self.mydir)
+                                     clean)
         elif self.getDebugInfo() == "dsym":
-            return self.buildDsym(architecture, compiler, dictionary,
-                                  clean, self.mydir)
+            return self.buildDsym(architecture, compiler, dictionary, clean)
         elif self.getDebugInfo() == "dwarf":
-            return self.buildDwarf(architecture, compiler, dictionary,
-                                   clean, self.mydir)
+            return self.buildDwarf(architecture, compiler, dictionary, clean)
         elif self.getDebugInfo() == "dwo":
             return self.buildDwo(architecture, compiler, dictionary,
-                                 clean, self.mydir)
+                                 clean)
         elif self.getDebugInfo() == "gmodules":
             return self.buildGModules(architecture, compiler, dictionary,
-                                      clean, self.mydir)
+                                      clean)
         else:
             self.fail("Can't build for debug info: %s" % self.getDebugInfo())
 

Modified: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py Tue Feb  6 10:22:51 2018
@@ -50,9 +50,10 @@ def getArchFlag():
 
     return ("ARCHFLAG=" + archflag) if archflag else ""
 
-def getMake(test_subdir):
+def getMake(test_subdir, test_name):
     """Returns the invocation for GNU make.
-       The argument test_subdir is the relative path to the testcase."""
+       The first argument is a tuple of the relative path to the testcase
+       and its filename stem."""
     if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
         make = "gmake"
     else:
@@ -61,19 +62,19 @@ def getMake(test_subdir):
     # Construct the base make invocation.
     lldb_test = os.environ["LLDB_TEST"]
     lldb_build = os.environ["LLDB_BUILD"]
-    if not (lldb_test and lldb_build and test_subdir and
+    if not (lldb_test and lldb_build and test_subdir and test_name and
             (not os.path.isabs(test_subdir))):
         raise Exception("Could not derive test directories")
-    build_dir = os.path.join(lldb_build, test_subdir)
-    test_dir = os.path.join(lldb_test, test_subdir)
+    build_dir = os.path.join(lldb_build, test_subdir, test_name)
+    src_dir = os.path.join(lldb_test, test_subdir)
     # This is a bit of a hack to make inline testcases work.
-    makefile = os.path.join(test_dir, "Makefile")
+    makefile = os.path.join(src_dir, "Makefile")
     if not os.path.isfile(makefile):
         makefile = os.path.join(build_dir, "Makefile")
     return [make,
-            "VPATH="+test_dir,
+            "VPATH="+src_dir,
             "-C", build_dir,
-            "-I", test_dir,
+            "-I", src_dir,
             "-f", makefile]
 
 
@@ -140,12 +141,13 @@ def buildDefault(
         compiler=None,
         dictionary=None,
         clean=True,
-        testdir=None):
+        testdir=None,
+        testname=None):
     """Build the binaries the default way."""
     commands = []
     if clean:
-        commands.append(getMake(testdir) + ["clean", getCmdLine(dictionary)])
-    commands.append(getMake(testdir) + ["all", getArchSpec(architecture),
+        commands.append(getMake(testdir, testname) + ["clean", getCmdLine(dictionary)])
+    commands.append(getMake(testdir, testname) + ["all", getArchSpec(architecture),
                      getCCSpec(compiler), getCmdLine(dictionary)])
 
     runBuildCommands(commands, sender=sender)
@@ -160,13 +162,16 @@ def buildDwarf(
         compiler=None,
         dictionary=None,
         clean=True,
-        testdir=None):
+        testdir=None,
+        testname=None):
     """Build the binaries with dwarf debug info."""
     commands = []
     if clean:
-        commands.append(getMake(testdir) + ["clean", getCmdLine(dictionary)])
-    commands.append(getMake(testdir) + ["MAKE_DSYM=NO", getArchSpec(
-        architecture), getCCSpec(compiler), getCmdLine(dictionary)])
+        commands.append(getMake(testdir, testname) +
+                        ["clean", getCmdLine(dictionary)])
+    commands.append(getMake(testdir, testname) +
+                    ["MAKE_DSYM=NO", getArchSpec(architecture),
+                     getCCSpec(compiler), getCmdLine(dictionary)])
 
     runBuildCommands(commands, sender=sender)
     # True signifies that we can handle building dwarf.
@@ -179,12 +184,14 @@ def buildDwo(
         compiler=None,
         dictionary=None,
         clean=True,
-        testdir=None):
+        testdir=None,
+        testname=None):
     """Build the binaries with dwarf debug info."""
     commands = []
     if clean:
-        commands.append(getMake(testdir) + ["clean", getCmdLine(dictionary)])
-    commands.append(getMake(testdir) +
+        commands.append(getMake(testdir, testname) +
+                        ["clean", getCmdLine(dictionary)])
+    commands.append(getMake(testdir, testname) +
                     ["MAKE_DSYM=NO", "MAKE_DWO=YES",
                      getArchSpec(architecture),
                      getCCSpec(compiler),
@@ -201,12 +208,14 @@ def buildGModules(
         compiler=None,
         dictionary=None,
         clean=True,
-        testdir=None):
+        testdir=None,
+        testname=None):
     """Build the binaries with dwarf debug info."""
     commands = []
     if clean:
-        commands.append(getMake(testdir) + ["clean", getCmdLine(dictionary)])
-    commands.append(getMake(testdir) +
+        commands.append(getMake(testdir, testname) +
+                        ["clean", getCmdLine(dictionary)])
+    commands.append(getMake(testdir, testname) +
                     ["MAKE_DSYM=NO",
                      "MAKE_GMODULES=YES",
                      getArchSpec(architecture),

Modified: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py Tue Feb  6 10:22:51 2018
@@ -11,13 +11,14 @@ def buildDsym(
         compiler=None,
         dictionary=None,
         clean=True,
-        testdir=None):
+        testdir=None,
+        testname=None):
     """Build the binaries with dsym debug info."""
     commands = []
-
     if clean:
-        commands.append(getMake(testdir) + ["clean", getCmdLine(dictionary)])
-    commands.append(getMake(testdir) +
+        commands.append(getMake(testdir, testname) +
+                        ["clean", getCmdLine(dictionary)])
+    commands.append(getMake(testdir, testname) +
                     ["MAKE_DSYM=YES",
                      getArchSpec(architecture),
                      getCCSpec(compiler),

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py Tue Feb  6 10:22:51 2018
@@ -20,9 +20,6 @@ class HelloWorldTestCase(TestBase):
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
-        # Get the full path to our executable to be attached/debugged.
-        self.exe = self.getBuildArtifact(self.testMethodName)
-        self.d = {'EXE': self.testMethodName}
         # Find a couple of the line numbers within main.c.
         self.line1 = line_number('main.c', '// Set break point at this line.')
         self.line2 = line_number('main.c', '// Waiting to be attached...')
@@ -37,9 +34,12 @@ class HelloWorldTestCase(TestBase):
     @skipIfiOSSimulator
     def test_with_process_launch_api(self):
         """Create target, breakpoint, launch a process, and then kill it."""
-        self.build(dictionary=self.d)
-        self.setTearDownCleanup(dictionary=self.d)
-        target = self.dbg.CreateTarget(self.exe)
+        # Get the full path to our executable to be attached/debugged.
+        exe = self.getBuildArtifact(self.testMethodName)
+        d = {'EXE': exe}
+        self.build(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        target = self.dbg.CreateTarget(exe)
 
         breakpoint = target.BreakpointCreateByLocation("main.c", self.line1)
 
@@ -82,12 +82,14 @@ class HelloWorldTestCase(TestBase):
     @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails
     def test_with_attach_to_process_with_id_api(self):
         """Create target, spawn a process, and attach to it with process id."""
-        self.build(dictionary=self.d)
-        self.setTearDownCleanup(dictionary=self.d)
-        target = self.dbg.CreateTarget(self.exe)
+        exe = self.getBuildArtifact(self.testMethodName)
+        d = {'EXE': exe}
+        self.build(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        target = self.dbg.CreateTarget(exe)
 
         # Spawn a new process
-        popen = self.spawnSubprocess(self.exe, ["abc", "xyz"])
+        popen = self.spawnSubprocess(exe, ["abc", "xyz"])
         self.addTearDownHook(self.cleanupSubprocesses)
 
         # Give the subprocess time to start and wait for user input
@@ -112,12 +114,14 @@ class HelloWorldTestCase(TestBase):
     @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails
     def test_with_attach_to_process_with_name_api(self):
         """Create target, spawn a process, and attach to it with process name."""
-        self.build(dictionary=self.d)
-        self.setTearDownCleanup(dictionary=self.d)
-        target = self.dbg.CreateTarget(self.exe)
+        exe = self.getBuildArtifact(self.testMethodName)
+        d = {'EXE': exe}
+        self.build(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        target = self.dbg.CreateTarget(exe)
 
         # Spawn a new process
-        popen = self.spawnSubprocess(self.exe, ["abc", "xyz"])
+        popen = self.spawnSubprocess(exe, ["abc", "xyz"])
         self.addTearDownHook(self.cleanupSubprocesses)
 
         # Give the subprocess time to start and wait for user input
@@ -127,7 +131,7 @@ class HelloWorldTestCase(TestBase):
         error = lldb.SBError()
         # Pass 'False' since we don't want to wait for new instance of
         # "hello_world" to be launched.
-        name = os.path.basename(self.exe)
+        name = os.path.basename(exe)
 
         # While we're at it, make sure that passing a None as the process name
         # does not hang LLDB.

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py Tue Feb  6 10:22:51 2018
@@ -19,6 +19,8 @@ class ProcessIOTestCase(TestBase):
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
+
+    def setup_test(self):
         # Get the full path to our executable to be debugged.
         self.exe = self.getBuildArtifact("process_io")
         self.local_input_file = self.getBuildArtifact("input.txt")
@@ -38,6 +40,7 @@ class ProcessIOTestCase(TestBase):
     @expectedFlakeyLinux(bugnumber="llvm.org/pr26437")
     def test_stdin_by_api(self):
         """Exercise SBProcess.PutSTDIN()."""
+        self.setup_test()
         self.build()
         self.create_target()
         self.run_process(True)
@@ -49,6 +52,7 @@ class ProcessIOTestCase(TestBase):
     @expectedFlakeyLinux(bugnumber="llvm.org/pr26437")
     def test_stdin_redirection(self):
         """Exercise SBLaunchInfo::AddOpenFileAction() for STDIN without specifying STDOUT or STDERR."""
+        self.setup_test()
         self.build()
         self.create_target()
         self.redirect_stdin()
@@ -62,6 +66,7 @@ class ProcessIOTestCase(TestBase):
     @skipIfDarwinEmbedded # debugserver can't create/write files on the device
     def test_stdout_redirection(self):
         """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT without specifying STDIN or STDERR."""
+        self.setup_test()
         self.build()
         self.create_target()
         self.redirect_stdout()
@@ -76,6 +81,7 @@ class ProcessIOTestCase(TestBase):
     @skipIfDarwinEmbedded # debugserver can't create/write files on the device
     def test_stderr_redirection(self):
         """Exercise SBLaunchInfo::AddOpenFileAction() for STDERR without specifying STDIN or STDOUT."""
+        self.setup_test()
         self.build()
         self.create_target()
         self.redirect_stderr()
@@ -90,6 +96,7 @@ class ProcessIOTestCase(TestBase):
     @skipIfDarwinEmbedded # debugserver can't create/write files on the device
     def test_stdout_stderr_redirection(self):
         """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR without redirecting STDIN."""
+        self.setup_test()
         self.build()
         self.create_target()
         self.redirect_stdout()

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py Tue Feb  6 10:22:51 2018
@@ -73,10 +73,7 @@ class SymbolContextAPITestCase(TestBase)
             str(compileUnit),
             "The compile unit should match",
             exe=False,
-            substrs=[
-                os.path.join(
-                    self.mydir,
-                    'main.c')])
+            substrs=[self.getSourcePath('main.c')])
 
         function = context.GetFunction()
         self.assertTrue(function)
@@ -92,8 +89,7 @@ class SymbolContextAPITestCase(TestBase)
             lineEntry.GetFileSpec().GetDirectory(),
             "The line entry should have the correct directory",
             exe=False,
-            substrs=[
-                self.mydir])
+            substrs=[self.mydir])
         self.expect(
             lineEntry.GetFileSpec().GetFilename(),
             "The line entry should have the correct filename",

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py Tue Feb  6 10:22:51 2018
@@ -22,7 +22,6 @@ class SymbolContextTwoFilesTestCase(Test
         """Test lookup by address in a module with multiple compilation units"""
         self.build()
         exe = self.getBuildArtifact("a.out")
-
         target = self.dbg.CreateTarget(exe)
         self.assertTrue(target, VALID_TARGET)
 
@@ -45,7 +44,6 @@ class SymbolContextTwoFilesTestCase(Test
         compile unit contains DW_AT_ranges and DW_AT_ranges_base attributes."""
         self.build()
         exe = self.getBuildArtifact("a.out")
-
         target = self.dbg.CreateTarget(exe)
         self.assertTrue(target, VALID_TARGET)
 

Modified: lldb/trunk/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py?rev=324368&r1=324367&r2=324368&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py Tue Feb  6 10:22:51 2018
@@ -20,16 +20,16 @@ class HelloWorldTestCase(TestBase):
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
-        # Get the full path to our executable to be attached/debugged.
-        self.exe = self.getBuildArtifact(self.testMethodName)
-        self.d = {'EXE': self.testMethodName}
 
     @add_test_categories(['pyapi'])
     def test_with_process_launch_api(self):
         """Test SBValue::GetValueDidChange"""
-        self.build(dictionary=self.d)
-        self.setTearDownCleanup(dictionary=self.d)
-        target = self.dbg.CreateTarget(self.exe)
+        # Get the full path to our executable to be attached/debugged.
+        exe = self.getBuildArtifact(self.testMethodName)
+        d = {'EXE': exe}
+        self.build(dictionary=d)
+        self.setTearDownCleanup(dictionary=d)
+        target = self.dbg.CreateTarget(exe)
 
         breakpoint = target.BreakpointCreateBySourceRegex(
             "break here", lldb.SBFileSpec("main.c"))




More information about the lldb-commits mailing list