aprantl updated this revision to Diff 132875.
aprantl added a comment.

Updated to query self.getDebugInfo() in getBuildDir().


https://reviews.llvm.org/D42763

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

Index: packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py
===================================================================
--- packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py
+++ packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py
@@ -20,16 +20,16 @@
     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"))
Index: packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py
===================================================================
--- packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py
+++ packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py
@@ -22,7 +22,6 @@
         """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 @@
         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)
 
Index: packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py
===================================================================
--- packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py
+++ packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py
@@ -73,10 +73,7 @@
             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 @@
             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",
Index: packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py
===================================================================
--- packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py
+++ packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py
@@ -19,6 +19,8 @@
     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 @@
     @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 @@
     @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 @@
     @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 @@
     @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 @@
     @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()
Index: packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
===================================================================
--- packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
+++ packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
@@ -20,9 +20,6 @@
     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 @@
     @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 @@
     @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 @@
     @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 @@
         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.
Index: packages/Python/lldbsuite/test/plugins/builder_darwin.py
===================================================================
--- packages/Python/lldbsuite/test/plugins/builder_darwin.py
+++ packages/Python/lldbsuite/test/plugins/builder_darwin.py
@@ -11,13 +11,14 @@
         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),
Index: packages/Python/lldbsuite/test/plugins/builder_base.py
===================================================================
--- packages/Python/lldbsuite/test/plugins/builder_base.py
+++ packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -50,30 +50,31 @@
 
     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:
         make = "make"
 
     # 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 @@
         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 @@
         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 @@
         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 @@
         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),
Index: packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -523,11 +523,14 @@
 
     @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 @@
         # 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 @@
 
     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."""
@@ -1517,93 +1502,108 @@
             compiler=None,
             dictionary=None,
             clean=True,
-            testdir=None):
+            testdir=None,
+            testname=None):
         """Platform specific way to build the default binaries."""
         if not testdir:
             testdir = self.mydir
+        if not testname:
+            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(
             self,
             architecture=None,
             compiler=None,
             dictionary=None,
             clean=True,
-            testdir=None):
+            testdir=None,
+            testname=None):
         """Platform specific way to build binaries with dsym info."""
         if not testdir:
             testdir = self.mydir
+        if not testname:
+            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(
             self,
             architecture=None,
             compiler=None,
             dictionary=None,
             clean=True,
-            testdir=None):
+            testdir=None,
+            testname=None):
         """Platform specific way to build binaries with dwarf maps."""
         if not testdir:
             testdir = self.mydir
+        if not testname:
+            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(
             self,
             architecture=None,
             compiler=None,
             dictionary=None,
             clean=True,
-            testdir=None):
+            testdir=None,
+            testname=None):
         """Platform specific way to build binaries with dwarf maps."""
         if not testdir:
             testdir = self.mydir
+        if not testname:
+            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(
             self,
             architecture=None,
             compiler=None,
             dictionary=None,
             clean=True,
-            testdir=None):
+            testdir=None,
+            testname=None):
         """Platform specific way to build binaries with gmodules info."""
         if not testdir:
             testdir = self.mydir
+        if not testname:
+            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 +1778,7 @@
                 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)
Index: packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- packages/Python/lldbsuite/test/lldbinline.py
+++ packages/Python/lldbsuite/test/lldbinline.py
@@ -92,9 +92,9 @@
             # 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()
Index: packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
+++ packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
@@ -22,17 +22,17 @@
         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):
         # Call super's setUp().
         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"""
Index: packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
+++ packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
@@ -22,13 +22,15 @@
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
-        lldbutil.mkdir_p(self.getBuildArtifact("hidden"))
         # 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,7 +96,7 @@
     @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'."""
-
+        self.setup_test()
         # Invoke the default build rule.
         self.build()
 
@@ -157,7 +159,7 @@
     @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."""
-
+        self.setup_test()
         # Invoke the default build rule.
         self.build()
         self.copy_shlibs_to_remote(hidden_dir=True)
@@ -222,7 +224,7 @@
     @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."""
-
+        self.setup_test()
         # Invoke the default build rule.
         self.build()
         self.copy_shlibs_to_remote()
@@ -296,7 +298,7 @@
     @skipIfFreeBSD  # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support
     def test_load_unload(self):
         """Test breakpoint by name works correctly with dlopen'ing."""
-
+        self.setup_test()
         # Invoke the default build rule.
         self.build()
         self.copy_shlibs_to_remote()
@@ -339,7 +341,7 @@
     @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."""
-
+        self.setup_test()
         # Invoke the default build rule.
         self.build()
         self.copy_shlibs_to_remote()
@@ -374,7 +376,7 @@
     @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.setup_test()
         self.build()
         self.copy_shlibs_to_remote()
 
Index: packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
@@ -28,17 +28,16 @@
         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):
         pwd_symlink = self.create_src_symlink()
         self.doBuild(pwd_symlink)
         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 @@
         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)
Index: packages/Python/lldbsuite/test/api/listeners/TestListener.py
===================================================================
--- packages/Python/lldbsuite/test/api/listeners/TestListener.py
+++ packages/Python/lldbsuite/test/api/listeners/TestListener.py
@@ -23,10 +23,10 @@
     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")
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to