3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-07-30 07:53:16 +00:00

print summary of line coverage to log

This commit is contained in:
N. Engelhardt 2025-07-16 13:40:07 +02:00
parent 8a4f465143
commit fb6974dcd7
2 changed files with 10 additions and 6 deletions

View file

@ -36,7 +36,7 @@ struct CoveragePass : public Pass {
log("\n"); log("\n");
log(" linecoverage [options] [selection]\n"); log(" linecoverage [options] [selection]\n");
log("\n"); log("\n");
log("This command writes coverage information on the design based on the current\n"); log("This command prints coverage information on the design based on the current\n");
log("selection, where items in the selection are considered covered and items not in\n"); log("selection, where items in the selection are considered covered and items not in\n");
log("the selection are considered uncovered. If the same source location is found\n"); log("the selection are considered uncovered. If the same source location is found\n");
log("both on items inside and out of the selection, it is considered uncovered.\n"); log("both on items inside and out of the selection, it is considered uncovered.\n");
@ -125,8 +125,12 @@ struct CoveragePass : public Pass {
log_debug("\n"); log_debug("\n");
} }
if(!ofile.empty()) { for (const auto& file_entry : all_lines) {
for (const auto& file_entry : all_lines) { int lines_found = file_entry.second.size();
int lines_hit = file_entry.second.size() - (uncovered_lines.count(file_entry.first) ? uncovered_lines[file_entry.first].size() : 0);
log("File %s: %d/%d lines covered\n", file_entry.first.c_str(), lines_hit, lines_found);
if(!ofile.empty()) {
fout << "SF:" << file_entry.first << "\n"; fout << "SF:" << file_entry.first << "\n";
for (int l : file_entry.second) { for (int l : file_entry.second) {
fout << "DA:" << l << ","; fout << "DA:" << l << ",";
@ -136,8 +140,8 @@ struct CoveragePass : public Pass {
fout << "1"; fout << "1";
fout << "\n"; fout << "\n";
} }
fout << "LF:" << file_entry.second.size() << "\n"; fout << "LF:" << lines_found << "\n";
fout << "LH:" << (uncovered_lines.count(file_entry.first) ? uncovered_lines[file_entry.first].size() : 0) << "\n"; fout << "LH:" << lines_hit << "\n";
fout << "end_of_record\n"; fout << "end_of_record\n";
} }
} }

View file

@ -40,5 +40,5 @@ DA:52,1
DA:53,0 DA:53,0
DA:56,1 DA:56,1
LF:40 LF:40
LH:24 LH:16
end_of_record end_of_record