From 41657ccf1762b6338327c031777936b39f7b101c Mon Sep 17 00:00:00 2001 From: Vince Harron Date: Thu, 21 May 2015 18:15:09 +0000 Subject: [PATCH] Modify dosep.py to add default session dir parameter 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 --- lldb/test/dosep.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lldb/test/dosep.py b/lldb/test/dosep.py index 8a4814b..29a865f 100755 --- a/lldb/test/dosep.py +++ b/lldb/test/dosep.py @@ -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 = [] @@ -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() @@ -113,10 +111,10 @@ out_q = None 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 @@ -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. @@ -229,8 +227,17 @@ Run lldb test suite using a separate process for each test file. 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: @@ -250,7 +257,7 @@ Run lldb test suite using a separate process for each test file. 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) -- 2.7.4