diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-08-29 18:37:05 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-08-29 18:37:05 +0000 |
commit | ff5982aa91d1ca0c11e00b3d2b22d32c66bb8590 (patch) | |
tree | a8d230f08520483336b9502d6722c4225aba5756 /lldb/packages/Python/lldbsuite | |
parent | 5a43fdd3139640116fc18d82cb1b6d2788def156 (diff) | |
download | bcm5719-llvm-ff5982aa91d1ca0c11e00b3d2b22d32c66bb8590.tar.gz bcm5719-llvm-ff5982aa91d1ca0c11e00b3d2b22d32c66bb8590.zip |
[test] Fix various module cache bugs and inconsistencies
Currently, lit tests don't set neither the module cache for building
inferiors nor the module cache used by lldb when running tests.
Furthermore, we have several places where we rely on the path to the
module cache being always the same, rather than passing the correct
value around. This makes it hard to specify a different module cache
path when debugging a a test.
This patch reworks how we determine and pass around the module cache
paths and fixes the omission on the lit side. It also adds a sanity
check to the lit and dotest suites.
Differential revision: https://reviews.llvm.org/D66966
llvm-svn: 370394
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
5 files changed, 56 insertions, 21 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 72f046e86d7..8bd17feacb1 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -106,6 +106,9 @@ lldb_platform_working_dir = None # The base directory in which the tests are being built. test_build_dir = None +# The clang module cache directory used by lldb. +module_cache_dir = None + # The only directory to scan for tests. If multiple test directories are # specified, and an exclusive test subdirectory is specified, the latter option # takes precedence. diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index d41bafb0fec..e8974a453c1 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -55,7 +55,7 @@ def get_dotest_invocation(): def is_exe(fpath): """Returns true if fpath is an executable.""" if fpath == None: - return False + return False return os.path.isfile(fpath) and os.access(fpath, os.X_OK) @@ -274,10 +274,10 @@ def parseOptionsAndInitTestdirs(): break if args.dsymutil: - os.environ['DSYMUTIL'] = args.dsymutil + os.environ['DSYMUTIL'] = args.dsymutil elif platform_system == 'Darwin': - os.environ['DSYMUTIL'] = seven.get_command_output( - 'xcrun -find -toolchain default dsymutil') + os.environ['DSYMUTIL'] = seven.get_command_output( + 'xcrun -find -toolchain default dsymutil') if args.filecheck: # The lldb-dotest script produced by the CMake build passes in a path @@ -426,6 +426,11 @@ def parseOptionsAndInitTestdirs(): configuration.lldb_platform_working_dir = args.lldb_platform_working_dir if args.test_build_dir: configuration.test_build_dir = args.test_build_dir + if args.module_cache_dir: + configuration.module_cache_dir = args.module_cache_dir + else: + configuration.module_cache_dir = os.path.join(configuration.test_build_dir, + 'module-cache-lldb') # Gather all the dirs passed on the command line. if len(args.args) > 0: @@ -869,16 +874,16 @@ def canRunWatchpointTests(): platform = lldbplatformutil.getPlatform() if platform == "netbsd": - if os.geteuid() == 0: - return True, "root can always write dbregs" - try: - output = subprocess.check_output(["/sbin/sysctl", "-n", - "security.models.extensions.user_set_dbregs"]).decode().strip() - if output == "1": - return True, "security.models.extensions.user_set_dbregs enabled" - except subprocess.CalledProcessError: - pass - return False, "security.models.extensions.user_set_dbregs disabled" + if os.geteuid() == 0: + return True, "root can always write dbregs" + try: + output = subprocess.check_output(["/sbin/sysctl", "-n", + "security.models.extensions.user_set_dbregs"]).decode().strip() + if output == "1": + return True, "security.models.extensions.user_set_dbregs enabled" + except subprocess.CalledProcessError: + pass + return False, "security.models.extensions.user_set_dbregs disabled" return True, "watchpoint support available" def checkWatchpointSupport(): diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py index fa36cbcef45..8de4d8dbb2f 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest_args.py +++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py @@ -147,6 +147,11 @@ def create_parser(): metavar='Test build directory', default='lldb-test-build.noindex', help='The root build directory for the tests. It will be removed before running.') + group.add_argument( + '--module-cache-dir', + dest='module_cache_dir', + metavar='The clang module cache directory used by LLDB', + help='The clang module cache directory used by LLDB. This is not the one used by the makefiles. Defaults to <test build directory>/module-cache-lldb.') # Configuration options group = parser.add_argument_group('Remote platform options') diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 6c00350167d..48dc81780e9 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1852,9 +1852,9 @@ class TestBase(Base): Base.setUp(self) # Set the clang modules cache path used by LLDB. - mod_cache = os.path.join(os.environ["LLDB_BUILD"], "module-cache-lldb") - self.runCmd('settings set symbols.clang-modules-cache-path "%s"' - % mod_cache) + self.runCmd( + 'settings set symbols.clang-modules-cache-path "{}"'.format( + configuration.module_cache_dir)) for s in self.setUpCommands(): self.runCmd(s) @@ -2058,13 +2058,13 @@ class TestBase(Base): if check: output = "" if self.res.GetOutput(): - output += "\nCommand output:\n" + self.res.GetOutput() + output += "\nCommand output:\n" + self.res.GetOutput() if self.res.GetError(): - output += "\nError output:\n" + self.res.GetError() + output += "\nError output:\n" + self.res.GetError() if msg: - msg += output + msg += output if cmd: - cmd += output + cmd += output self.assertTrue(self.res.Succeeded(), msg if (msg) else CMD_MSG(cmd)) diff --git a/lldb/packages/Python/lldbsuite/test/sanity/TestModuleCacheSanity.py b/lldb/packages/Python/lldbsuite/test/sanity/TestModuleCacheSanity.py new file mode 100644 index 00000000000..2ce00d4e7ca --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/sanity/TestModuleCacheSanity.py @@ -0,0 +1,22 @@ +""" +This is a sanity check that verifies that the module cache path is set +correctly and points inside the default test build directory. +""" + +from __future__ import print_function + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +class ModuleCacheSanityTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def test(self): + self.expect( + 'settings show symbols.clang-modules-cache-path', + substrs=['lldb-test-build.noindex', 'module-cache-lldb']) |