-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LIT] Have lit run the lldb test suite
This is the first in what will hopefully become a series of patches to replace the driver logic in dotest.py with LIT. The motivation for this change is that there's no point in maintaining two driver implementations. Since all of the LLVM projects are using lit, this is the obvious choice. Obviously the goal is maintain full compatibility with the functionality offered by dotest. As such we won't be removing anything until that point has been reached. This patch is the initial attempt (referred to as v1) to run the lldb test suite with lit. To do so we introduced a custom LLDB test format that invokes dotest.py with a single test file. Differential revision: https://reviews.llvm.org/D45333 llvm-svn: 330275
- Loading branch information
1 parent
75a4e52
commit 1a928f3
Showing
4 changed files
with
133 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- Python -*- | ||
|
||
# Configuration file for the 'lit' test runner. | ||
|
||
import os | ||
|
||
import lit.formats | ||
|
||
# name: The name of this test suite. | ||
config.name = 'lldb-Suite' | ||
|
||
# suffixes: A list of file extensions to treat as test files. | ||
config.suffixes = ['.py'] | ||
|
||
# test_source_root: The root path where tests are located. | ||
# test_exec_root: The root path where tests should be run. | ||
config.test_source_root = os.path.join(config.lldb_src_root, 'packages','Python','lldbsuite','test') | ||
config.test_exec_root = config.test_source_root | ||
|
||
# Build dotest command. | ||
dotest_cmd = [config.dotest_path, '-q'] | ||
dotest_cmd.extend(config.dotest_args_str.split(';')) | ||
|
||
# Load LLDB test format. | ||
sys.path.append(os.path.join(config.lldb_src_root, "lit", "Suite")) | ||
import lldbtest | ||
|
||
# testFormat: The test format to use to interpret tests. | ||
config.test_format = lldbtest.LLDBTest(dotest_cmd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@LIT_SITE_CFG_IN_HEADER@ | ||
|
||
config.test_exec_root = "@LLVM_BINARY_DIR@" | ||
config.llvm_src_root = "@LLVM_SOURCE_DIR@" | ||
config.llvm_obj_root = "@LLVM_BINARY_DIR@" | ||
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" | ||
config.llvm_libs_dir = "@LLVM_LIBS_DIR@" | ||
config.llvm_build_mode = "@LLVM_BUILD_MODE@" | ||
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" | ||
config.lldb_obj_root = "@LLDB_BINARY_DIR@" | ||
config.lldb_src_root = "@LLDB_SOURCE_DIR@" | ||
config.target_triple = "@TARGET_TRIPLE@" | ||
config.python_executable = "@PYTHON_EXECUTABLE@" | ||
config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py" | ||
config.dotest_args_str = "@LLDB_DOTEST_ARGS@" | ||
|
||
# Support substitution of the tools and libs dirs with user parameters. This is | ||
# used when we can't determine the tool dir at configuration time. | ||
try: | ||
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params | ||
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params | ||
config.llvm_build_mode = config.llvm_build_mode % lit_config.params | ||
except KeyError as e: | ||
key, = e.args | ||
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) | ||
|
||
# Let the main config do the real work. | ||
lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Suite/lit.cfg") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
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 | ||
|
||
|
||
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.unsupported: | ||
return (lit.Test.UNSUPPORTED, 'Test is unsupported') | ||
|
||
testPath, testFile = os.path.split(test.getSourcePath()) | ||
cmd = self.dotest_cmd + [testPath, '-p', testFile] | ||
|
||
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: | ||
return lit.Test.FAIL, 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:\n\n%s%s' % | ||
(passing_test_line, out, err)) | ||
return lit.Test.UNRESOLVED, msg | ||
|
||
return lit.Test.PASS, '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters