← 返回命令列表

Linux command

lcov 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Capture coverage data

lcov --capture --directory [.] --output-file [coverage.info]

Generate HTML report

genhtml [coverage.info] --output-directory [coverage/]

Remove patterns

lcov --remove [coverage.info] '*/test/*' -o [filtered.info]

Extract specific files

lcov --extract [coverage.info] '*/src/*' -o [src.info]

Combine traces

lcov --add-tracefile [a.info] --add-tracefile [b.info] -o [combined.info]

Zero counters

lcov --zerocounters --directory [.]

说明

lcov processes gcov code coverage data. It collects and manipulates coverage information. The tool generates coverage reports from gcc/gcov data. Use genhtml to create HTML reports.

参数

--capture
Capture coverage data.
--directory _DIR_
Source directory.
--output-file _FILE_
Output trace file.
--remove _FILE_ _PATTERN_
Remove matching files.
--extract _FILE_ _PATTERN_
Extract matching files.
--add-tracefile _FILE_
Add trace file.
--help
Display help information.

FAQ

What is the lcov command used for?

lcov processes gcov code coverage data. It collects and manipulates coverage information. The tool generates coverage reports from gcc/gcov data. Use genhtml to create HTML reports.

How do I run a basic lcov example?

Run `lcov --capture --directory [.] --output-file [coverage.info]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --capture do in lcov?

Capture coverage data.