diff --git a/misc/tests/conftest.py b/misc/tests/conftest.py new file mode 100644 index 0000000000..5cd17c61d6 --- /dev/null +++ b/misc/tests/conftest.py @@ -0,0 +1,8 @@ +def pytest_addoption(parser): + parser.addoption("--suppress", action="append", default=[], + help="Suppression files used in test-memory-leaks.py. These files must be located in the folder valgrind.") + +def pytest_generate_tests(metafunc): + if "suppression_files" in metafunc.fixturenames: + tags = list(metafunc.config.option.suppress) + metafunc.parametrize("suppression_files", [tags], scope='session') diff --git a/misc/tests/test-memory-leaks.py b/misc/tests/test-memory-leaks.py index 44b75aa025..5769c1dfb6 100644 --- a/misc/tests/test-memory-leaks.py +++ b/misc/tests/test-memory-leaks.py @@ -17,8 +17,6 @@ DOWNWARD_BIN = os.path.join(BUILD_DIR, "bin", "downward") SAS_FILE = os.path.join(REPO, "test.sas") PLAN_FILE = os.path.join(REPO, "test.plan") -VALGRIND_GCC5_SUPPRESSION_FILE = os.path.join( - REPO, "misc", "tests", "valgrind", "gcc5.supp") DLOPEN_SUPPRESSION_FILE = os.path.join( REPO, "misc", "tests", "valgrind", "dlopen.supp") DL_CATCH_ERROR_SUPPRESSION_FILE = os.path.join( @@ -31,33 +29,20 @@ CONFIGS.update(configs.default_configs_optimal(core=True, extended=True)) CONFIGS.update(configs.default_configs_satisficing(core=True, extended=True)) - -def escape_list(l): - return " ".join(pipes.quote(x) for x in l) - - -def get_compiler_and_version(): - output = subprocess.check_output( - ["cmake", "-LA", "-N", "../../src/"], cwd=BUILD_DIR).decode("utf-8") - compiler = re.search( - "^DOWNWARD_CXX_COMPILER_ID:STRING=(.+)$", output, re.M).group(1) - version = re.search( - "^DOWNWARD_CXX_COMPILER_VERSION:STRING=(.+)$", output, re.M).group(1) - return compiler, version - - -COMPILER, COMPILER_VERSION = get_compiler_and_version() SUPPRESSION_FILES = [ DLOPEN_SUPPRESSION_FILE, DL_CATCH_ERROR_SUPPRESSION_FILE, ] -if COMPILER == "GNU" and COMPILER_VERSION.split(".")[0] == "5": - print("Using leak suppression file for GCC 5 " - "(see https://issues.fast-downward.org/issue703).") - SUPPRESSION_FILES.append(VALGRIND_GCC5_SUPPRESSION_FILE) + +def escape_list(l): + return " ".join(pipes.quote(x) for x in l) -def run_plan_script(task, config): +def run_plan_script(task, config, custom_suppression_files): + custom_suppression_files = [ + os.path.join(REPO, "misc", "tests", "valgrind", f) + for f in custom_suppression_files + ] assert "--alias" not in config, config cmd = [ "valgrind", @@ -66,7 +51,7 @@ def run_plan_script(task, config): "--show-leak-kinds=all", "--errors-for-leak-kinds=all", "--track-origins=yes"] - for suppression_file in SUPPRESSION_FILES: + for suppression_file in SUPPRESSION_FILES + custom_suppression_files: cmd.append("--suppressions={}".format(suppression_file)) cmd.extend([DOWNWARD_BIN] + config + ["--internal-plan-file", PLAN_FILE]) print("\nRun: {}".format(escape_list(cmd))) @@ -101,8 +86,8 @@ def setup_module(_module): @pytest.mark.parametrize("config", sorted(CONFIGS.values())) -def test_configs(config): - run_plan_script(SAS_FILE, config) +def test_configs(config, suppression_files): + run_plan_script(SAS_FILE, config, suppression_files) def teardown_module(_module): diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4de0067d5a..0930e65e00 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,12 +46,6 @@ set(FAST_DOWNWARD_MAIN_CMAKELISTS_READ TRUE) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) -# Write compiler ID and version to the cache to allow retrieving this information -# with "cmake -LA" (see test-memory-leaks.py). -set(DOWNWARD_CXX_COMPILER_ID ${CMAKE_CXX_COMPILER_ID} CACHE STRING "") -set(DOWNWARD_CXX_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION} CACHE STRING "") -mark_as_advanced(DOWNWARD_CXX_COMPILER_ID DOWNWARD_CXX_COMPILER_VERSION) - # Add planner components as subprojects. # Copy the translator into the output directory.