Skip to content

Commit 8a9dbc3

Browse files
committed
CP-17268 cleaner integrates coverage profiling: make coverage
To set up a build for coverage profiling, use "make coverage" followed by "make". This should it make possible to interate this code into the main line. Supporting code lives in profiling/. All other changes to the code are concerned with better signal handling and should likewise go into the main line. Signed-off-by: Christian Lindig <[email protected]>
1 parent 7a25ada commit 8a9dbc3

20 files changed

+466
-117
lines changed

COVERAGE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
# Coverage Analysis
3+
4+
This project can be compiled for coverage analysis using [bisect_ppx]. By
5+
default, this is not done. To compile for coverage analysis, do:
6+
7+
make coverage
8+
make
9+
10+
The `coverage` target adds the rules in `_tags.coverage` to the `_tags`
11+
file, which in turn causes all code to be compiled for coverage
12+
analysis. The `_tags.coverage` file could be tweaked to control which
13+
files get instrumented.
14+
15+
## Support Files
16+
17+
See [profiling/coverage.ml](./profiling/coverage.ml) for the run-time
18+
setup of coverage profiling. This code has no effect when not profiling
19+
during execution. Once [bixect_ppx] has better defaults we could get rid
20+
of it.
21+
22+
## Execution and Logging
23+
24+
During program execution, a binary writes coverage data to
25+
26+
/tmp/bisect-lunarossa-*.out
27+
28+
This can be overridden by setting the `BISECT_FILE` environment
29+
variable, which is otherwise set at startup using the code in
30+
`profiling/coverage.ml`;
31+
32+
## Analysis
33+
34+
See the [bisect_ppx] documentation for details but try from the
35+
top-level directory:
36+
37+
bisect-ppx-report -I _build -html coverage /tmp/bisect-*.out
38+
39+
This creates an HTML document in [coverage/](./coverage].
40+
41+
[bisect_ppx]: https://github.com/aantron/bisect_ppx
42+
43+
44+
45+

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,19 @@ release:
9797
grep -v 'warn-error' _oasis > _oasis.tmp
9898
mv _oasis.tmp _oasis
9999
oasis setup
100+
101+
# make coverage
102+
# prepares for building with coverage analysis
103+
#
104+
# make uncover
105+
# reverses the setup from "make coverage"
106+
107+
coverage: _tags _tags.coverage
108+
test ! -f _tags.orig && mv _tags _tags.orig || true
109+
cat _tags.coverage _tags.orig > _tags
110+
111+
uncover: _tags.orig
112+
mv _tags.orig _tags
113+
114+
.PHONY: default coverage uncover
115+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ binaries with an evironment variable pointing to a better place:
2929

3030
Function `Bisect_setup.init name` sets the environment variable if it is
3131
unset from inside the program such that log data is written to the temp
32-
directory (repecting TMP and TEMP env vars id set). However, logging to
32+
directory (respecting TMP and TEMP env vars if set). However, logging to
3333
$CWD will still work even if the `init` function is not called.
3434

3535

_oasis

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ Flag simulator
2323
Description: Build server with simulator support
2424
Default: true
2525

26+
27+
# Support files for profiling
28+
Library profiling
29+
CompiledObject: best
30+
Path: profiling
31+
Install: false
32+
Findlibname: profiling
33+
Modules: Coverage
34+
BuildDepends:
35+
2636
Library xenopsd
2737
CompiledObject: best
2838
Path: lib
@@ -53,7 +63,6 @@ Library xenopsd
5363
Xenstore,
5464
Version
5565
BuildDepends:
56-
bisect_ppx,
5766
threads,
5867
threads.posix,
5968
uuidm,
@@ -86,10 +95,10 @@ Executable set_domain_uuid
8695
MainIs: set_domain_uuid.ml
8796
Install: false
8897
BuildDepends:
89-
bisect_ppx,
9098
xenctrl,
9199
uuidm,
92-
cmdliner
100+
cmdliner,
101+
profiling
93102

94103
Executable suspend_image_viewer
95104
CompiledObject: best
@@ -99,9 +108,9 @@ Executable suspend_image_viewer
99108
MainIs: suspend_image_viewer.ml
100109
Install: false
101110
BuildDepends:
102-
bisect_ppx,
103111
xenopsd,
104-
cmdliner
112+
cmdliner,
113+
profiling
105114

106115
Executable xenopsd_xc_main
107116
CompiledObject: best
@@ -113,7 +122,6 @@ Executable xenopsd_xc_main
113122
Custom: true
114123
Install: false
115124
BuildDepends:
116-
bisect_ppx,
117125
xenctrl,
118126
xenopsd,
119127
xenstore,
@@ -128,7 +136,8 @@ Executable xenopsd_xc_main
128136
xcp.rrd,
129137
rrd,
130138
sexplib,
131-
xcp-inventory
139+
xcp-inventory,
140+
profiling
132141
CSources: fsync_stubs.c, xenctrlext_stubs.c
133142

134143
Executable watch_test
@@ -139,13 +148,13 @@ Executable watch_test
139148
MainIs: watch_test.ml
140149
Install: false
141150
BuildDepends:
142-
bisect_ppx,
143151
xenopsd,
144152
xenstore,
145153
xenstore.unix,
146154
xenstore_transport,
147155
xenstore_transport.unix,
148-
threads
156+
threads,
157+
profiling
149158

150159
Executable xenopsd_simulator
151160
CompiledObject: best
@@ -157,8 +166,8 @@ Executable xenopsd_simulator
157166
Custom: true
158167
Install: false
159168
BuildDepends:
160-
bisect_ppx,
161-
xenopsd
169+
xenopsd,
170+
profiling
162171

163172
Executable xenopsd_libvirt_main
164173
CompiledObject: best
@@ -170,14 +179,14 @@ Executable xenopsd_libvirt_main
170179
Custom: true
171180
Install: false
172181
BuildDepends:
173-
bisect_ppx,
174182
xenopsd,
175183
rpclib,
176184
forkexec,
177185
xcp,
178186
xcp.storage,
179187
sexplib,
180-
libvirt
188+
libvirt,
189+
profiling
181190

182191
Executable xenopsd_xenlight_main
183192
CompiledObject: best
@@ -189,7 +198,6 @@ Executable xenopsd_xenlight_main
189198
Custom: true
190199
Install: false
191200
BuildDepends:
192-
bisect_ppx,
193201
xenlight,
194202
xentoollog,
195203
xenctrl,
@@ -205,6 +213,7 @@ Executable xenopsd_xenlight_main
205213
xcp.memory,
206214
sexplib,
207215
xcp-inventory,
208-
optcomp
216+
optcomp,
217+
profiling
209218
CSources: fsync_stubs.c, poll_stubs.c
210219

0 commit comments

Comments
 (0)