From 76571de51794e00d6cac80773fca8690849522ff Mon Sep 17 00:00:00 2001 From: Viktor Ashirov Date: Jan 21 2020 21:20:39 +0000 Subject: Issue 50627 - Add ASAN logs to HTML report Bug Description: ASAN log files were rotated even when HTML report was not used. Fix Description: Rotate the ASAN log files only when pytest-html plugin is installed and a path to the HTML report is provided. Relates: https://pagure.io/389-ds-base/issue/50627 Reviewed by: mreynolds (Thanks!) --- diff --git a/dirsrvtests/conftest.py b/dirsrvtests/conftest.py index f8710b3..9bf6f32 100644 --- a/dirsrvtests/conftest.py +++ b/dirsrvtests/conftest.py @@ -78,14 +78,21 @@ def log_test_name_to_journald(request): @pytest.fixture(scope="function", autouse=True) def rotate_xsan_logs(request): - if p.asan_enabled: - xsan_logs_dir = f'{p.run_dir}/bak' - if not os.path.exists(xsan_logs_dir): - os.mkdir(xsan_logs_dir) - else: - for f in glob.glob(f'{p.run_dir}/ns-slapd-*san*'): - shutil.move(f, xsan_logs_dir) - return rotate_xsan_logs + # Do we have a pytest-html installed? + pytest_html = request.config.pluginmanager.getplugin('html') + if pytest_html is not None: + # We have it installed, but let's check if we actually use it (--html=report.html) + pytest_htmlpath = request.config.getoption('htmlpath') + if p.asan_enabled and pytest_htmlpath is not None: + # ASAN is enabled and an HTML report was requested, + # rotate the ASAN logs so that only relevant logs are attached to the case in the report. + xsan_logs_dir = f'{p.run_dir}/bak' + if not os.path.exists(xsan_logs_dir): + os.mkdir(xsan_logs_dir) + else: + for f in glob.glob(f'{p.run_dir}/ns-slapd-*san*'): + shutil.move(f, xsan_logs_dir) + return rotate_xsan_logs @pytest.hookimpl(hookwrapper=True)