Skip to content

Commit 3c49cc0

Browse files
committed
Fixup the issue where lcov capture fails due to a long path
The full test case name is onger than before. The lcov output file was created in test_result/test_debugdir, which caused the lcov command to fail. Moving the file to test_result to avoid this issue. Signed-off-by: Yingshun Cui <yicui@redhat.com>
1 parent e6a3d8b commit 3c49cc0

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

virttest/env_process.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,30 +1332,34 @@ def postprocess(test, params, env):
13321332
test_name = params.get("shortname", getattr(test, "name", "unknown_test"))
13331333
if hasattr(test_name, "uid"):
13341334
test_name = str(test_name.uid)
1335+
# Save to test-results/gcov_libvirt/ to avoid long path issues
1336+
# test.debugdir is typically: .../test-results/{test-dir}/
1337+
# Navigate up to test-results/ and create gcov_qemu/ there
1338+
test_results_dir = os.path.dirname(test.debugdir)
1339+
gcov_qemu_dir = os.path.join(test_results_dir, "gcov_qemu")
1340+
os.makedirs(gcov_qemu_dir, exist_ok=True)
13351341

13361342
if gcov_format == "lcov":
13371343
try:
13381344
path.find_command("lcov")
13391345
except path.CmdNotFoundError:
13401346
LOG.warning("lcov package not installed, cannot collect QEMU coverage")
13411347
else:
1342-
gcov_qemu_dir = utils_misc.get_path(test.debugdir, "gcov_qemu")
13431348
collect_lcov_coverage(qemu_builddir, gcov_qemu_dir, test_name, "qemu")
13441349

13451350
if params.get("gcov_qemu_compress", "no") == "yes":
1346-
os.chdir(test.debugdir)
1351+
os.chdir(gcov_qemu_dir)
13471352
archive.compress("gcov_qemu.tar.gz", gcov_qemu_dir)
13481353
shutil.rmtree(gcov_qemu_dir, ignore_errors=True)
13491354
else:
13501355
if utils_package.package_install("gcovr"):
1351-
gcov_qemu_dir = utils_misc.get_path(test.debugdir, "gcov_qemu")
13521356
collect_cmd_opts = params.get("gcov_qemu_collect_cmd_opts", "--html")
13531357
collect_gcovr_coverage(
13541358
qemu_builddir, gcov_qemu_dir, "qemu", collect_cmd_opts
13551359
)
13561360

13571361
if params.get("gcov_qemu_compress", "no") == "yes":
1358-
os.chdir(test.debugdir)
1362+
os.chdir(gcov_qemu_dir)
13591363
archive.compress("gcov_qemu.tar.gz", gcov_qemu_dir)
13601364
shutil.rmtree(gcov_qemu_dir, ignore_errors=True)
13611365
else:
@@ -1369,6 +1373,13 @@ def postprocess(test, params, env):
13691373
if hasattr(test_name, "uid"):
13701374
test_name = str(test_name.uid)
13711375

1376+
# Save to test-results/gcov_libvirt/ to avoid long path issues
1377+
# test.debugdir is typically: .../test-results/{test-dir}/
1378+
# Navigate up to test-results/ and create gcov_libvirt/ there
1379+
test_results_dir = os.path.dirname(test.debugdir)
1380+
gcov_libvirt_dir = os.path.join(test_results_dir, "gcov_libvirt")
1381+
os.makedirs(gcov_libvirt_dir, exist_ok=True)
1382+
13721383
if gcov_format == "lcov":
13731384
try:
13741385
path.find_command("lcov")
@@ -1377,25 +1388,23 @@ def postprocess(test, params, env):
13771388
"lcov package not installed, cannot collect libvirt coverage"
13781389
)
13791390
else:
1380-
gcov_libvirt_dir = utils_misc.get_path(test.debugdir, "gcov_libvirt")
13811391
collect_lcov_coverage(
13821392
libvirt_builddir, gcov_libvirt_dir, test_name, "libvirt"
13831393
)
13841394

13851395
if params.get("gcov_libvirt_compress", "no") == "yes":
1386-
os.chdir(test.debugdir)
1396+
os.chdir(gcov_libvirt_dir)
13871397
archive.compress("gcov_libvirt.tar.gz", gcov_libvirt_dir)
13881398
shutil.rmtree(gcov_libvirt_dir, ignore_errors=True)
13891399
else:
13901400
if utils_package.package_install("gcovr"):
1391-
gcov_libvirt_dir = utils_misc.get_path(test.debugdir, "gcov_libvirt")
13921401
collect_cmd_opts = params.get("gcov_libvirt_collect_cmd_opts", "--html")
13931402
collect_gcovr_coverage(
13941403
libvirt_builddir, gcov_libvirt_dir, "libvirt", collect_cmd_opts
13951404
)
13961405

13971406
if params.get("gcov_libvirt_compress", "no") == "yes":
1398-
os.chdir(test.debugdir)
1407+
os.chdir(gcov_libvirt_dir)
13991408
archive.compress("gcov_libvirt.tar.gz", gcov_libvirt_dir)
14001409
shutil.rmtree(gcov_libvirt_dir, ignore_errors=True)
14011410
else:

0 commit comments

Comments
 (0)