diff options
| author | Adrian Prantl <aprantl@apple.com> | 2018-02-06 18:22:51 +0000 | 
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2018-02-06 18:22:51 +0000 | 
| commit | 332351d9b98f993e4d0eb83a98ff4d4bb619b541 (patch) | |
| tree | 342ad2040a651b28809035213b74aa0719f4910b /lldb/packages/Python/lldbsuite/test | |
| parent | 2f6412c38962193f085f7830fd54e693579a35d2 (diff) | |
| download | llvm-332351d9b98f993e4d0eb83a98ff4d4bb619b541.zip llvm-332351d9b98f993e4d0eb83a98ff4d4bb619b541.tar.gz llvm-332351d9b98f993e4d0eb83a98ff4d4bb619b541.tar.bz2 | |
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
llvm-svn: 324368
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
13 files changed, 131 insertions, 148 deletions
| diff --git a/lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py b/lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py index 760a379..6b6a37e 100644 --- a/lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py +++ b/lldb/packages/Python/lldbsuite/test/api/listeners/TestListener.py @@ -23,10 +23,10 @@ class ListenToModuleLoadedEvents (TestBase):      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") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py index 86ef0d7..7f78c86 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py @@ -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) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py index 7fb1cb4..d4af8c0 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py @@ -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") diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py index 7e0aa92..5b72f5e 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py @@ -22,8 +22,10 @@ class TestValueOfVectorVariableTestCase(TestBase):          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):          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""" diff --git a/lldb/packages/Python/lldbsuite/test/lldbinline.py b/lldb/packages/Python/lldbsuite/test/lldbinline.py index db35486..0b84749 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbinline.py +++ b/lldb/packages/Python/lldbsuite/test/lldbinline.py @@ -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() diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index ce1acca..e202dc2 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -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()) diff --git a/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py b/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py index 5114c06..dd5024c 100644 --- a/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py +++ b/lldb/packages/Python/lldbsuite/test/plugins/builder_base.py @@ -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), diff --git a/lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py b/lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py index d71bc3b..61642bc 100644 --- a/lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py +++ b/lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py @@ -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), diff --git a/lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py b/lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py index 5ab4fad..f42eb88 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py @@ -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. diff --git a/lldb/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py b/lldb/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py index 0be3402..e25083d 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py @@ -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() diff --git a/lldb/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py b/lldb/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py index c546cf8..2b783fb 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py @@ -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", diff --git a/lldb/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py b/lldb/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py index 41e44ee..8640abe 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py @@ -22,7 +22,6 @@ class SymbolContextTwoFilesTestCase(TestBase):          """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(TestBase):          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) diff --git a/lldb/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py b/lldb/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py index e4795f2..a83fd6e 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py @@ -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")) | 
