Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 809fb94

Browse files
ANDROID: Specify temporary directory to create-tracefile.py
create-tracefile.py supports --tmp-dir. The script decompresses .gcno.tar.gz and creates the gcov script in the directory. This argument lets the user run the script outside of a source tree. Bug: 355559072 Test: common/tools/testing/android/bin/create-tracefile.py \ -t logs --tmp-dir out/tmp-dir Change-Id: Idcb791277d448c846ed2a74c2b693b64dfb77c99 Signed-off-by: Hsin-Yi Chen <hsinyichen@google.com>
1 parent 702044d commit 809fb94

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

tools/testing/android/bin/create-tracefile.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131

3232
LCOV = "lcov"
3333

34+
# Relative to the root of the source tree..
35+
OUTPUT_COV_DIR = os.path.join("out", "coverage")
36+
37+
PREBUILT_LLVM_COV_PATH = os.path.join(
38+
"prebuilts", "clang", "host", "linux-x86", "llvm-binutils-stable",
39+
"llvm-cov"
40+
)
41+
3442
EXCLUDED_FILES = [
3543
"*/security/selinux/av_permissions.h",
3644
"*/security/selinux/flask.h",
@@ -360,7 +368,7 @@ def get_kernel_repo_dir() -> str:
360368
return get_parent_path(this_script_full_path, 6)
361369

362370

363-
def build_config(llvm_cov_path: str) -> {}:
371+
def build_config(llvm_cov_path: str, tmp_dir: str) -> {}:
364372
"""Build configuration.
365373
366374
Returns:
@@ -369,12 +377,14 @@ def build_config(llvm_cov_path: str) -> {}:
369377
config = {}
370378
config["repo_dir"] = get_kernel_repo_dir()
371379
config["output_dir"] = f'{config["repo_dir"]}/out'
372-
config["output_cov_dir"] = f'{config["output_dir"]}/coverage'
380+
config["output_cov_dir"] = (
381+
os.path.abspath(tmp_dir) if tmp_dir else
382+
os.path.join(config["repo_dir"], OUTPUT_COV_DIR)
383+
)
373384

374385
config["llvm_cov_filename"] = (
375386
os.path.abspath(llvm_cov_path) if llvm_cov_path else
376-
f'{config["repo_dir"]}/prebuilts/clang/host/linux-x86/'
377-
'llvm-binutils-stable/llvm-cov'
387+
os.path.join(config["repo_dir"], PREBUILT_LLVM_COV_PATH)
378388
)
379389

380390
config["llvm_gcov_sh_filename"] = (
@@ -430,7 +440,18 @@ def main() -> None:
430440
arg_parser.add_argument(
431441
"--llvm-cov",
432442
required=False,
433-
help="Path to llvm-cov",
443+
help=(
444+
"Path to llvm-cov. Default: " +
445+
os.path.join("<repo dir>", PREBUILT_LLVM_COV_PATH)
446+
)
447+
)
448+
arg_parser.add_argument(
449+
"--tmp-dir",
450+
required=False,
451+
help=(
452+
"Path to the directory where the temporary files are created."
453+
" Default: " + os.path.join("<repo dir>", OUTPUT_COV_DIR)
454+
)
434455
)
435456
arg_parser.add_argument(
436457
"--verbose",
@@ -463,7 +484,7 @@ def main() -> None:
463484
logging.error("%s is not a directory.", gcno_dir)
464485
sys.exit(-1)
465486

466-
config = build_config(args.llvm_cov)
487+
config = build_config(args.llvm_cov, args.tmp_dir)
467488

468489
if args.gcno_dirs:
469490
gcno_mappings = read_gcno_dirs(args.gcno_dirs)

0 commit comments

Comments
 (0)