Skip to content

Commit

Permalink
Updated test-memory-leaks to take command line parameters for suppres…
Browse files Browse the repository at this point in the history
…sion files, removed writing out cxx compiler version in cmake.
  • Loading branch information
salome-eriksson committed Aug 2, 2023
1 parent 0213ac1 commit 0f0b6d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 32 deletions.
8 changes: 8 additions & 0 deletions misc/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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')
37 changes: 11 additions & 26 deletions misc/tests/test-memory-leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
Expand All @@ -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)))
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 0 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0f0b6d6

Please sign in to comment.