Skip to content

Commit

Permalink
Modify dosep.py to add default session dir parameter
Browse files Browse the repository at this point in the history
This ensures that all spawned dotest instances store their traces
in the same location.

Test Plan:
run dosep.py with and without a -s option for dotest

cd lldb/test
./dosep.py
./dosep.py -o '-s /tmp/traces'

Differential Revision: http://reviews.llvm.org/D9839

llvm-svn: 237923
  • Loading branch information
vharron committed May 21, 2015
1 parent 2f8e607 commit 41657cc
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lldb/test/dosep.py
Expand Up @@ -70,7 +70,7 @@ def call_with_timeout(command, timeout):
return (ePassed if subprocess.call(command, stdin=subprocess.PIPE) == 0
else eFailed)

def process_dir(root, files, test_root, dotest_options):
def process_dir(root, files, test_root, dotest_argv):
"""Examine a directory for tests, and invoke any found within it."""
timed_out = []
failed = []
Expand All @@ -87,10 +87,8 @@ def process_dir(root, files, test_root, dotest_options):
continue

script_file = os.path.join(test_root, "dotest.py")
is_posix = (os.name == "posix")
split_args = shlex.split(dotest_options, posix=is_posix) if dotest_options else []
command = ([sys.executable, script_file] +
split_args +
dotest_argv +
["-p", name, root])

timeout_name = os.path.basename(os.path.splitext(name)[0]).upper()
Expand All @@ -113,10 +111,10 @@ def process_dir(root, files, test_root, dotest_options):
def process_dir_worker(arg_tuple):
"""Worker thread main loop when in multithreaded mode.
Takes one directory specification at a time and works on it."""
(root, files, test_root, dotest_options) = arg_tuple
return process_dir(root, files, test_root, dotest_options)
(root, files, test_root, dotest_argv) = arg_tuple
return process_dir(root, files, test_root, dotest_argv)

def walk_and_invoke(test_directory, test_subdir, dotest_options, num_threads):
def walk_and_invoke(test_directory, test_subdir, dotest_argv, num_threads):
"""Look for matched files and invoke test driver on each one.
In single-threaded mode, each test driver is invoked directly.
In multi-threaded mode, submit each test driver to a worker
Expand All @@ -129,7 +127,7 @@ def walk_and_invoke(test_directory, test_subdir, dotest_options, num_threads):
# Collect the test files that we'll run.
test_work_items = []
for root, dirs, files in os.walk(test_subdir, topdown=False):
test_work_items.append((root, files, test_directory, dotest_options))
test_work_items.append((root, files, test_directory, dotest_argv))

# Run the items, either in a pool (for multicore speedup) or
# calling each individually.
Expand Down Expand Up @@ -229,8 +227,17 @@ def main():
opts, args = parser.parse_args()
dotest_option_string = opts.dotest_options

dotest_argv = shlex.split(dotest_option_string)
is_posix = (os.name == "posix")
dotest_argv = shlex.split(dotest_option_string, posix=is_posix) if dotest_option_string else []
dotest_options = dotest_args.getArguments(dotest_argv)
if not dotest_options.s:
# no session log directory, we need to add this to prevent
# every dotest invocation from creating its own directory
import datetime
# The windows platforms don't like ':' in the pathname.
timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
dotest_argv.append('-s')
dotest_argv.append(timestamp_started)

# The root directory was specified on the command line
if len(args) == 0:
Expand All @@ -250,7 +257,7 @@ def main():
num_threads = 1

system_info = " ".join(platform.uname())
(timed_out, failed, passed) = walk_and_invoke(test_directory, test_subdir, dotest_option_string,
(timed_out, failed, passed) = walk_and_invoke(test_directory, test_subdir, dotest_argv,
num_threads)
timed_out = set(timed_out)
num_tests = len(failed) + len(passed)
Expand Down

0 comments on commit 41657cc

Please sign in to comment.