diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-10-09 16:38:47 +0000 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-10-09 16:38:47 +0000 |
| commit | 22314179f0660c172514b397060fd8f34b586e82 (patch) | |
| tree | afb3f04cd285733772ffceec4ccf3d8539dca91c /lldb/lit/Suite/lldbtest.py | |
| parent | df14bd315db94d286c0c75b4b6ee5d760f311399 (diff) | |
| download | bcm5719-llvm-22314179f0660c172514b397060fd8f34b586e82.tar.gz bcm5719-llvm-22314179f0660c172514b397060fd8f34b586e82.zip | |
[test] Split LLDB tests into API, Shell & Unit
LLDB has three major testing strategies: unit tests, tests that exercise
the SB API though dotest.py and what we currently call lit tests. The
later is rather confusing as we're now using lit as the driver for all
three types of tests. As most of this grew organically, the directory
structure in the LLDB repository doesn't really make this clear.
The 'lit' tests are part of the root and among these tests there's a
Unit and Suite folder for the unit and dotest-tests. This layout makes
it impossible to run just the lit tests.
This patch changes the directory layout to match the 3 testing
strategies, each with their own directory and their own configuration
file. This means there are now 3 directories under lit with 3
corresponding targets:
- API (check-lldb-api): Test exercising the SB API.
- Shell (check-lldb-shell): Test exercising command line utilities.
- Unit (check-lldb-unit): Unit tests.
Finally, there's still the `check-lldb` target that runs all three test
suites.
Finally, this also renames the lit folder to `test` to match the LLVM
repository layout.
Differential revision: https://reviews.llvm.org/D68606
llvm-svn: 374184
Diffstat (limited to 'lldb/lit/Suite/lldbtest.py')
| -rw-r--r-- | lldb/lit/Suite/lldbtest.py | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/lldb/lit/Suite/lldbtest.py b/lldb/lit/Suite/lldbtest.py deleted file mode 100644 index 99eb1457259..00000000000 --- a/lldb/lit/Suite/lldbtest.py +++ /dev/null @@ -1,116 +0,0 @@ -from __future__ import absolute_import -import os - -import subprocess -import sys - -import lit.Test -import lit.TestRunner -import lit.util -from lit.formats.base import TestFormat - -def getBuildDir(cmd): - found = False - for arg in cmd: - if found: - return arg - if arg == '--build-dir': - found = True - return None - -def mkdir_p(path): - import errno - try: - os.makedirs(path) - except OSError as e: - if e.errno != errno.EEXIST: - raise - if not os.path.isdir(path): - raise OSError(errno.ENOTDIR, "%s is not a directory"%path) - -class LLDBTest(TestFormat): - def __init__(self, dotest_cmd): - self.dotest_cmd = dotest_cmd - - def getTestsInDirectory(self, testSuite, path_in_suite, litConfig, - localConfig): - source_path = testSuite.getSourcePath(path_in_suite) - for filename in os.listdir(source_path): - # Ignore dot files and excluded tests. - if (filename.startswith('.') or filename in localConfig.excludes): - continue - - # Ignore files that don't start with 'Test'. - if not filename.startswith('Test'): - continue - - filepath = os.path.join(source_path, filename) - if not os.path.isdir(filepath): - base, ext = os.path.splitext(filename) - if ext in localConfig.suffixes: - yield lit.Test.Test(testSuite, path_in_suite + - (filename, ), localConfig) - - def execute(self, test, litConfig): - if litConfig.noExecute: - return lit.Test.PASS, '' - - if test.config.lldb_disable_python: - return (lit.Test.UNSUPPORTED, 'Python module disabled') - - if test.config.unsupported: - return (lit.Test.UNSUPPORTED, 'Test is unsupported') - - testPath, testFile = os.path.split(test.getSourcePath()) - # On Windows, the system does not always correctly interpret - # shebang lines. To make sure we can execute the tests, add - # python exe as the first parameter of the command. - cmd = [sys.executable] + self.dotest_cmd + [testPath, '-p', testFile] - - # The macOS system integrity protection (SIP) doesn't allow injecting - # libraries into system binaries, but this can be worked around by - # copying the binary into a different location. - if 'DYLD_INSERT_LIBRARIES' in test.config.environment and \ - (sys.executable.startswith('/System/') or \ - sys.executable.startswith('/usr/')): - builddir = getBuildDir(cmd) - mkdir_p(builddir) - copied_python = os.path.join(builddir, 'copied-system-python') - if not os.path.isfile(copied_python): - import shutil, subprocess - python = subprocess.check_output([ - '/usr/bin/python2.7', '-c', - 'import sys; print sys.executable']).strip() - shutil.copy(python, copied_python) - cmd[0] = copied_python - - try: - out, err, exitCode = lit.util.executeCommand( - cmd, - env=test.config.environment, - timeout=litConfig.maxIndividualTestTime) - except lit.util.ExecuteCommandTimeoutException: - return (lit.Test.TIMEOUT, 'Reached timeout of {} seconds'.format( - litConfig.maxIndividualTestTime)) - - if exitCode: - # Match FAIL but not XFAIL. - for line in out.splitlines() + err.splitlines(): - if line.startswith('FAIL:'): - return lit.Test.FAIL, out + err - - if 'XPASS:' in out or 'XPASS:' in err: - return lit.Test.XPASS, out + err - - has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err - has_passing_tests = 'PASS:' in out or 'PASS:' in err - if has_unsupported_tests and not has_passing_tests: - return lit.Test.UNSUPPORTED, out + err - - passing_test_line = 'RESULT: PASSED' - if passing_test_line not in out and passing_test_line not in err: - msg = ('Unable to find %r in dotest output (exit code %d):\n\n%s%s' - % (passing_test_line, exitCode, out, err)) - return lit.Test.UNRESOLVED, msg - - return lit.Test.PASS, '' |

