Skip to content

Commit c3c76bf

Browse files
authored
Document how to get code coverage. (#339)
* Document how to get code coverage. Change-Id: If7eae6008ad0394490885f88b6edb8436d9f54f3 * Remove (hopefully insignificant) whitespace. Change-Id: Ie4079dd2998c616ae5b6e5b031e29cea5f11d9f8
1 parent 42be17a commit c3c76bf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

HACKING

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,32 @@ patch:
7777
src/openocd -s ../tcl -f /path/to/openocd.cfg
7878
@endcode
7979

80+
- Runtime coverage testing
81+
82+
Apply the following patch to prevent OpenOCD from killing itself:
83+
@code
84+
--- a/src/openocd.c
85+
+++ b/src/openocd.c
86+
@@ -372,8 +372,6 @@ int openocd_main(int argc, char *argv[])
87+
88+
if (ERROR_FAIL == ret)
89+
return EXIT_FAILURE;
90+
- else if (ERROR_OK != ret)
91+
- exit_on_signal(ret);
92+
93+
return ret;
94+
}
95+
@endcode
96+
97+
Configure your OpenOCD binary with coverage support as follows:
98+
@code
99+
LDFLAGS="-fprofile-arcs -ftest-coverage"
100+
CFLAGS="-fprofile-arcs -ftest-coverage" ./configure
101+
@endcode
102+
103+
Now every time OpenOCD is run, coverage info in your build directory is
104+
updated. Running `gcov src/path/file.c` will generate a report.
105+
80106
Please consider performing these additonal checks where appropriate
81107
(especially Clang Static Analyzer for big portions of new code) and
82108
mention the results (e.g. "Valgrind-clean, no new Clang analyzer

0 commit comments

Comments
 (0)