Skip to content

Commit f40550e

Browse files
author
Jon Ludlam
committed
Merge pull request #267 from lindig/coverage
CP-17268 integrate coverage profiling
2 parents 900f9ec + 5d87a67 commit f40550e

23 files changed

+569
-53
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-<binary>-*.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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,20 @@ release:
9797
grep -v 'warn-error' _oasis > _oasis.tmp
9898
mv _oasis.tmp _oasis
9999
oasis setup
100+
101+
# make coverage - prepares for building with coverage analysis
102+
# make uncover - reverses the setup from "make coverage"
103+
# make report - create coverage/index.html
104+
105+
coverage: _tags _tags.coverage
106+
test ! -f _tags.orig && mv _tags _tags.orig || true
107+
cat _tags.coverage _tags.orig > _tags
108+
109+
uncover: _tags.orig
110+
mv _tags.orig _tags
111+
112+
report:
113+
bisect-ppx-report -I _build -html coverage /tmp/bisect-xenops*out
114+
115+
.PHONY: report coverage uncover
116+

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ xenopsd manages VMs running
99

1010
and provides a simple RPC control interface to the layer above (typically xapi).
1111

12+
## Coverage Profiling
13+
14+
This code can be profiled for coverage. See [COVERAGE.md].
15+
16+
17+
[COVERAGE.md]: ./COVERAGE.md
18+

_oasis

Lines changed: 120 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,68 @@ 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
2939
Findlibname: xenopsd
3040
ByteOpt: -warn-error +a
3141
NativeOpt: -warn-error +a
32-
Modules: Suspend_image, Cancellable_subprocess, Bootloader, Ionice, Mac, Xenops_migrate, Xenops_hooks, Task_server, Xenops_task, Updates, Xenops_utils, Xenops_server, Xenopsd, Xenops_server_plugin, Xenops_server_skeleton, Scheduler, Path, Storage, Interface, Xenctrl_uuid, Xenstore, Version
33-
BuildDepends: threads, threads.posix, uuidm, xmlm, cohttp, uri, rpclib, rpclib.syntax, forkexec, fd-send-recv, xcp, xcp.xen, xcp.storage, sexplib, sexplib.syntax, xcp, uutf, xenstore, xenstore.unix, xenstore_transport, xenstore_transport.unix, oclock
42+
Modules:
43+
Suspend_image,
44+
Cancellable_subprocess,
45+
Bootloader,
46+
Ionice,
47+
Mac,
48+
Xenops_migrate,
49+
Xenops_hooks,
50+
Task_server,
51+
Xenops_task,
52+
Updates,
53+
Xenops_utils,
54+
Xenops_server,
55+
Xenopsd,
56+
Xenops_server_plugin,
57+
Xenops_server_skeleton,
58+
Scheduler,
59+
Path,
60+
Storage,
61+
Interface,
62+
Xenctrl_uuid,
63+
Xenstore,
64+
Version
65+
BuildDepends:
66+
threads,
67+
threads.posix,
68+
uuidm,
69+
xmlm,
70+
cohttp,
71+
uri,
72+
rpclib,
73+
rpclib.syntax,
74+
forkexec,
75+
fd-send-recv,
76+
xcp,
77+
xcp.xen,
78+
xcp.storage,
79+
sexplib,
80+
sexplib.syntax,
81+
xcp,
82+
uutf,
83+
xenstore,
84+
xenstore.unix,
85+
xenstore_transport,
86+
xenstore_transport.unix,
87+
oclock
3488
CSources: sockopt_stubs.c
3589

3690
Executable set_domain_uuid
@@ -40,7 +94,11 @@ Executable set_domain_uuid
4094
NativeOpt: -warn-error +a-3
4195
MainIs: set_domain_uuid.ml
4296
Install: false
43-
BuildDepends: xenctrl, uuidm, cmdliner
97+
BuildDepends:
98+
xenctrl,
99+
uuidm,
100+
cmdliner,
101+
profiling
44102

45103
Executable suspend_image_viewer
46104
CompiledObject: best
@@ -49,7 +107,10 @@ Executable suspend_image_viewer
49107
NativeOpt: -warn-error +a-3
50108
MainIs: suspend_image_viewer.ml
51109
Install: false
52-
BuildDepends: xenopsd, cmdliner
110+
BuildDepends:
111+
xenopsd,
112+
cmdliner,
113+
profiling
53114

54115
Executable xenopsd_xc_main
55116
CompiledObject: best
@@ -60,7 +121,23 @@ Executable xenopsd_xc_main
60121
Build$: flag(xen)
61122
Custom: true
62123
Install: false
63-
BuildDepends: xenctrl, xenopsd, xenstore, xenstore.unix, xenstore_transport, xenstore_transport.unix, rpclib, forkexec, xcp, xcp.storage, xcp.memory, xcp.rrd, rrd, sexplib, xcp-inventory
124+
BuildDepends:
125+
xenctrl,
126+
xenopsd,
127+
xenstore,
128+
xenstore.unix,
129+
xenstore_transport,
130+
xenstore_transport.unix,
131+
rpclib,
132+
forkexec,
133+
xcp,
134+
xcp.storage,
135+
xcp.memory,
136+
xcp.rrd,
137+
rrd,
138+
sexplib,
139+
xcp-inventory,
140+
profiling
64141
CSources: fsync_stubs.c, xenctrlext_stubs.c
65142

66143
Executable watch_test
@@ -70,7 +147,14 @@ Executable watch_test
70147
NativeOpt: -warn-error +a-3
71148
MainIs: watch_test.ml
72149
Install: false
73-
BuildDepends: xenopsd, xenstore, xenstore.unix, xenstore_transport, xenstore_transport.unix, threads
150+
BuildDepends:
151+
xenopsd,
152+
xenstore,
153+
xenstore.unix,
154+
xenstore_transport,
155+
xenstore_transport.unix,
156+
threads,
157+
profiling
74158

75159
Executable xenopsd_simulator
76160
CompiledObject: best
@@ -81,7 +165,9 @@ Executable xenopsd_simulator
81165
Build$: flag(simulator)
82166
Custom: true
83167
Install: false
84-
BuildDepends: xenopsd
168+
BuildDepends:
169+
xenopsd,
170+
profiling
85171

86172
Executable xenopsd_libvirt_main
87173
CompiledObject: best
@@ -92,7 +178,15 @@ Executable xenopsd_libvirt_main
92178
Build$: flag(libvirt)
93179
Custom: true
94180
Install: false
95-
BuildDepends: xenopsd, rpclib, forkexec, xcp, xcp.storage, sexplib, libvirt
181+
BuildDepends:
182+
xenopsd,
183+
rpclib,
184+
forkexec,
185+
xcp,
186+
xcp.storage,
187+
sexplib,
188+
libvirt,
189+
profiling
96190

97191
Executable xenopsd_xenlight_main
98192
CompiledObject: best
@@ -103,6 +197,23 @@ Executable xenopsd_xenlight_main
103197
Build$: flag(xenlight)
104198
Custom: true
105199
Install: false
106-
BuildDepends: xenlight, xentoollog, xenctrl, xenopsd, xenstore, xenstore.unix, xenstore_transport, xenstore_transport.unix, rpclib, forkexec, xcp, xcp.storage, xcp.memory, sexplib, xcp-inventory, optcomp
200+
BuildDepends:
201+
xenlight,
202+
xentoollog,
203+
xenctrl,
204+
xenopsd,
205+
xenstore,
206+
xenstore.unix,
207+
xenstore_transport,
208+
xenstore_transport.unix,
209+
rpclib,
210+
forkexec,
211+
xcp,
212+
xcp.storage,
213+
xcp.memory,
214+
sexplib,
215+
xcp-inventory,
216+
optcomp,
217+
profiling
107218
CSources: fsync_stubs.c, poll_stubs.c
108219

0 commit comments

Comments
 (0)