From e97b991eef63663d1f635813fe375354edb7b51a Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Fri, 4 Dec 2020 11:42:36 +0100 Subject: [PATCH] [lldb] Remove LLDB session dir and just store test traces in the respective test build directory Test runs log some of their output to files inside the LLDB session dir. This session dir is shared between all tests, so all the tests have to make sure they choose a unique file name inside that directory. We currently choose by default `-` as the log file name. However, that means that if not every test class in the test suite has a unique class name, then we end up with a race condition as two tests will try to write to the same log file. I already tried in D83767 changing the format to use the test file basename instead (which we already require to be unique for some other functionality), but it seems the code for getting the basename didn't work on Windows. This patch instead just changes that dotest stores the log files in the build directory for the current test. We know that directory is unique for this test, so no need to generate some unique file name now. Also removes all the environment vars and parameters related to the now unused session dir. The new log paths now look like this for a failure in 'TestCppOperators`: ``` ./lldb-test-build.noindex/lang/cpp/operators/TestCppOperators.test_dwarf/Failure.log ./lldb-test-build.noindex/lang/cpp/operators/TestCppOperators.test_dsym/Failure.log ./lldb-test-build.noindex/lang/cpp/operators/TestCppOperators.test_gmodules/Failure.log ``` Reviewed By: labath Differential Revision: https://reviews.llvm.org/D92498 --- lldb/examples/test/.lldb-loggings | 3 +- lldb/examples/test/usage-lldb-loggings | 3 +- .../Python/lldbsuite/test/configuration.py | 14 ------- lldb/packages/Python/lldbsuite/test/dotest.py | 19 +-------- lldb/packages/Python/lldbsuite/test/dotest_args.py | 10 ----- lldb/packages/Python/lldbsuite/test/lldbtest.py | 46 ++++------------------ lldb/test/API/CMakeLists.txt | 6 --- lldb/test/API/lit.cfg.py | 3 -- lldb/test/API/lit.site.cfg.py.in | 1 - lldb/utils/lldb-dotest/CMakeLists.txt | 5 --- lldb/utils/lldb-dotest/lldb-dotest.in | 2 - 11 files changed, 11 insertions(+), 101 deletions(-) diff --git a/lldb/examples/test/.lldb-loggings b/lldb/examples/test/.lldb-loggings index 9c92bd9..873bb88 100644 --- a/lldb/examples/test/.lldb-loggings +++ b/lldb/examples/test/.lldb-loggings @@ -3,8 +3,7 @@ def pre_flight(self): import lldb import lldbtest - dname = os.path.join(os.environ["LLDB_TEST"], - os.environ["LLDB_SESSION_DIRNAME"]) + dname = os.path.join(os.environ["LLDB_TEST"]) if not os.path.isdir(dname): os.mkdir(dname) dest = os.path.join(dname, "lldb_log-%s-%s-%s.txt" % (self.getArchitecture(), self.getCompiler(), self.id())) diff --git a/lldb/examples/test/usage-lldb-loggings b/lldb/examples/test/usage-lldb-loggings index b7d7e2e..4ce9689 100644 --- a/lldb/examples/test/usage-lldb-loggings +++ b/lldb/examples/test/usage-lldb-loggings @@ -88,8 +88,7 @@ lldb.pre_flight: def pre_flight(self): import lldb import lldbtest - dname = os.path.join(os.environ["LLDB_TEST"], - os.environ["LLDB_SESSION_DIRNAME"]) + dname = os.path.join(os.environ["LLDB_TEST"]) if not os.path.isdir(dname): os.mkdir(dname) dest = os.path.join(dname, "lldb_log-%s-%s-%s.txt" % (self.getArchitecture(), self.getCompiler(), self.id())) diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 7939a27..db4262f 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -76,20 +76,6 @@ regexp = None skip_tests = None xfail_tests = None -# By default, recorded session info for errored/failed test are dumped into its -# own file under a session directory named after the timestamp of the test suite -# run. Use '-s session-dir-name' to specify a specific dir name. -sdir_name = None - -# Valid options: -# f - test file name (without extension) -# n - test class name -# m - test method name -# a - architecture -# c - compiler path -# The default is to write all fields. -session_file_format = 'fnmac' - # Set this flag if there is any session info dumped during the test run. sdir_has_content = False # svn_info stores the output from 'svn info lldb.base.dir'. diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 7c0a9ec..64a1978 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -388,14 +388,6 @@ def parseOptionsAndInitTestdirs(): usage(parser) configuration.regexp = args.p - if args.s: - configuration.sdir_name = args.s - else: - timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S") - configuration.sdir_name = os.path.join(os.getcwd(), timestamp_started) - - configuration.session_file_format = args.session_file_format - if args.t: os.environ['LLDB_COMMAND_TRACE'] = 'YES' @@ -972,14 +964,6 @@ def run_suite(): # Install the control-c handler. unittest2.signals.installHandler() - lldbutil.mkdir_p(configuration.sdir_name) - os.environ["LLDB_SESSION_DIRNAME"] = configuration.sdir_name - - sys.stderr.write( - "\nSession logs for test failures/errors/unexpected successes" - " will go into directory '%s'\n" % - configuration.sdir_name) - # # Invoke the default TextTestRunner to run the test suite # @@ -1033,8 +1017,7 @@ def run_suite(): if configuration.sdir_has_content and configuration.verbose: sys.stderr.write( "Session logs for test failures/errors/unexpected successes" - " can be found in directory '%s'\n" % - configuration.sdir_name) + " can be found in the test build directory\n") if configuration.use_categories and len( configuration.failures_per_category) > 0: diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py index 48d754e..c77f4c2 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest_args.py +++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py @@ -124,16 +124,6 @@ def create_parser(): action='append', help='Run "setting set SETTING VALUE" before executing any test.') group.add_argument( - '-s', - metavar='name', - help='Specify the name of the dir created to store the session files of tests with errored or failed status. If not specified, the test driver uses the timestamp as the session dir name') - group.add_argument( - '-S', - '--session-file-format', - default=configuration.session_file_format, - metavar='format', - help='Specify session file name format. See configuration.py for a description.') - group.add_argument( '-y', type=int, metavar='count', diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 7ba3a15..53d1aa4 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -868,6 +868,11 @@ class Base(unittest2.TestCase): # List of log files produced by the current test. self.log_files = [] + # Create the build directory. + # The logs are stored in the build directory, so we have to create it + # before creating the first log file. + self.makeBuildDir() + session_file = self.getLogBasenameForCurrentTest()+".log" self.log_files.append(session_file) @@ -930,8 +935,6 @@ class Base(unittest2.TestCase): self.lib_lldb = lib self.darwinWithFramework = self.platformIsDarwin() - self.makeBuildDir() - def setAsync(self, value): """ Sets async mode to True/False and ensures it is reset after the testcase completes.""" old_async = self.dbg.GetAsync() @@ -1156,45 +1159,12 @@ class Base(unittest2.TestCase): def getRerunArgs(self): return " -f %s.%s" % (self.__class__.__name__, self._testMethodName) - def getLogBasenameForCurrentTest(self, prefix=None): + def getLogBasenameForCurrentTest(self, prefix="Incomplete"): """ returns a partial path that can be used as the beginning of the name of multiple log files pertaining to this test - - /--.. """ - dname = os.path.join(configuration.test_src_root, - os.environ["LLDB_SESSION_DIRNAME"]) - if not os.path.isdir(dname): - os.mkdir(dname) - - components = [] - if prefix is not None: - components.append(prefix) - for c in configuration.session_file_format: - if c == 'f': - components.append(self.__class__.__module__) - elif c == 'n': - components.append(self.__class__.__name__) - elif c == 'c': - compiler = self.getCompiler() - - if compiler[1] == ':': - compiler = compiler[2:] - if os.path.altsep is not None: - compiler = compiler.replace(os.path.altsep, os.path.sep) - path_components = [x for x in compiler.split(os.path.sep) if x != ""] - - # Add at most 4 path components to avoid generating very long - # filenames - components.extend(path_components[-4:]) - elif c == 'a': - components.append(self.getArchitecture()) - elif c == 'm': - components.append(self.testMethodName) - fname = "-".join(components) - - return os.path.join(dname, fname) + return os.path.join(self.getBuildDir(), prefix) def dumpSessionInfo(self): """ @@ -1254,7 +1224,7 @@ class Base(unittest2.TestCase): # process the log files if prefix != 'Success' or lldbtest_config.log_success: # keep all log files, rename them to include prefix - src_log_basename = self.getLogBasenameForCurrentTest(None) + src_log_basename = self.getLogBasenameForCurrentTest() dst_log_basename = self.getLogBasenameForCurrentTest(prefix) for src in self.log_files: if os.path.isfile(src): diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt index f4802e2..2f2ced1 100644 --- a/lldb/test/API/CMakeLists.txt +++ b/lldb/test/API/CMakeLists.txt @@ -36,14 +36,10 @@ set(LLDB_TEST_USER_ARGS # hash of filename and .text section, there *will* be conflicts inside # the build directory. set(LLDB_TEST_COMMON_ARGS - -S nm -u CXXFLAGS -u CFLAGS ) -# Configure the traces directory. -set(LLDB_TEST_TRACE_DIRECTORY "${PROJECT_BINARY_DIR}/lldb-test-traces" CACHE PATH "The test traces directory.") - # Set the path to the default lldb test executable. set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}") @@ -142,7 +138,6 @@ if(LLDB_BUILT_STANDALONE) string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_FRAMEWORK_DIR "${LLDB_FRAMEWORK_DIR}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}") - string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_TRACE_DIRECTORY "${LLDB_TEST_TRACE_DIRECTORY}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}") @@ -172,7 +167,6 @@ endif() string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}") string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_SOURCE_DIR "${LLDB_SOURCE_DIR}") string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_BUILD_DIRECTORY "${LLDB_TEST_BUILD_DIRECTORY}") -string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_TRACE_DIRECTORY "${LLDB_TEST_TRACE_DIRECTORY}") string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_EXECUTABLE "${LLDB_TEST_EXECUTABLE}") string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_COMPILER "${LLDB_TEST_COMPILER}") string(REPLACE ${CMAKE_CFG_INTDIR} ${dotest_args_replacement} LLDB_TEST_DSYMUTIL "${LLDB_TEST_DSYMUTIL}") diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index 8f28192..aa63192 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -191,9 +191,6 @@ if is_configured('test_arch'): if is_configured('lldb_build_directory'): dotest_cmd += ['--build-dir', config.lldb_build_directory] -if is_configured('lldb_trace_directory'): - dotest_cmd += ['-s', config.lldb_trace_directory] - if is_configured('lldb_module_cache'): delete_module_cache(config.lldb_module_cache) dotest_cmd += ['--lldb-module-cache-dir', config.lldb_module_cache] diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index ce2ff8e..86f135b 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -19,7 +19,6 @@ config.shared_libs = @LLVM_ENABLE_SHARED_LIBS@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" config.target_triple = "@TARGET_TRIPLE@" config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@" -config.lldb_trace_directory = "@LLDB_TEST_TRACE_DIRECTORY@" config.lldb_reproducer_directory = os.path.join("@LLDB_TEST_BUILD_DIRECTORY@", "reproducers") config.python_executable = "@Python3_EXECUTABLE@" config.dotest_args_str = "@LLDB_DOTEST_ARGS@" diff --git a/lldb/utils/lldb-dotest/CMakeLists.txt b/lldb/utils/lldb-dotest/CMakeLists.txt index cba04f3..1001fbf 100644 --- a/lldb/utils/lldb-dotest/CMakeLists.txt +++ b/lldb/utils/lldb-dotest/CMakeLists.txt @@ -23,7 +23,6 @@ if(LLDB_BUILT_STANDALONE) string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}") - string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_TRACE_DIRECTORY_CONFIGURED "${LLDB_TEST_TRACE_DIRECTORY}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}") string(REPLACE ${LLVM_RUNTIME_OUTPUT_INTDIR} ${config_runtime_output_dir} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}") @@ -38,7 +37,6 @@ if(LLDB_BUILT_STANDALONE) string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}") string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}") string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}") - string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_TRACE_DIRECTORY_CONFIGURED "${LLDB_TEST_TRACE_DIRECTORY}") string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}") string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}") string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}") @@ -52,7 +50,6 @@ if(LLDB_BUILT_STANDALONE) string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}") string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}") string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}") - string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_TRACE_DIRECTORY_CONFIGURED "${LLDB_TEST_TRACE_DIRECTORY}") string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}") string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}") string(REPLACE ${CMAKE_CFG_INTDIR} "." LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}") @@ -74,7 +71,6 @@ elseif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}") string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}") string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}") - string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_TRACE_DIRECTORY_CONFIGURED "${LLDB_TEST_TRACE_DIRECTORY}") string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}") string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}") string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}") @@ -93,7 +89,6 @@ else() set(LLDB_SOURCE_DIR_CONFIGURED "${LLDB_SOURCE_DIR}") set(LLDB_FRAMEWORK_DIR_CONFIGURED "${LLDB_FRAMEWORK_DIR}") set(LLDB_TEST_BUILD_DIRECTORY_CONFIGURED "${LLDB_TEST_BUILD_DIRECTORY}") - set(LLDB_TEST_TRACE_DIRECTORY_CONFIGURED "${LLDB_TEST_TRACE_DIRECTORY}") set(LLDB_TEST_EXECUTABLE_CONFIGURED "${LLDB_TEST_EXECUTABLE}") set(LLDB_TEST_COMPILER_CONFIGURED "${LLDB_TEST_COMPILER}") set(LLDB_TEST_DSYMUTIL_CONFIGURED "${LLDB_TEST_DSYMUTIL}") diff --git a/lldb/utils/lldb-dotest/lldb-dotest.in b/lldb/utils/lldb-dotest/lldb-dotest.in index d669689..8d4e27b 100755 --- a/lldb/utils/lldb-dotest/lldb-dotest.in +++ b/lldb/utils/lldb-dotest/lldb-dotest.in @@ -15,7 +15,6 @@ lldb_build_dir = '@LLDB_TEST_BUILD_DIRECTORY_CONFIGURED@' lldb_build_intel_pt = "@LLDB_BUILD_INTEL_PT@" lldb_framework_dir = "@LLDB_FRAMEWORK_DIR_CONFIGURED@" lldb_libs_dir = "@LLDB_LIBS_DIR_CONFIGURED@" -lldb_trace_dir = '@LLDB_TEST_TRACE_DIRECTORY_CONFIGURED@' if __name__ == '__main__': wrapper_args = sys.argv[1:] @@ -24,7 +23,6 @@ if __name__ == '__main__': cmd = [sys.executable, dotest_path] cmd.extend(['--arch', arch]) cmd.extend(dotest_args) - cmd.extend(['-s', lldb_trace_dir]) cmd.extend(['--build-dir', lldb_build_dir]) cmd.extend(['--executable', executable]) cmd.extend(['--compiler', compiler]) -- 2.7.4