Skip to content

Commit ca5e0b1

Browse files
committed
8282493: Add --with-jcov-modules convenience option
Reviewed-by: erikj
1 parent a72f750 commit ca5e0b1

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

doc/testing.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,13 @@ <h4 id="jcov">JCOV</h4>
411411
special target <code>jcov-test</code> instead of <code>test</code>, e.g.
412412
<code>make jcov-test TEST=jdk_lang</code>. This will make sure the JCov
413413
image is built, and that JCov reporting is enabled.</p>
414+
<p>To include JCov coverage for just a subset of all modules, you can
415+
use the <code>--with-jcov-modules</code> arguments to
416+
<code>configure</code>, e.g.
417+
<code>--with-jcov-modules=jdk.compiler,java.desktop</code>.</p>
418+
<p>For more fine-grained control, you can pass arbitrary filters to JCov
419+
using <code>--with-jcov-filters</code>, and you can specify a specific
420+
JDK to instrument using <code>--with-jcov-input-jdk</code>.</p>
414421
<p>The JCov report is stored in
415422
<code>build/$BUILD/test-results/jcov-output/report</code>.</p>
416423
<p>Please note that running with JCov reporting can be very memory

doc/testing.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,14 @@ The simplest way to run tests with JCov coverage report is to use the special
345345
target `jcov-test` instead of `test`, e.g. `make jcov-test TEST=jdk_lang`. This
346346
will make sure the JCov image is built, and that JCov reporting is enabled.
347347

348+
To include JCov coverage for just a subset of all modules, you can use the
349+
`--with-jcov-modules` arguments to `configure`, e.g.
350+
`--with-jcov-modules=jdk.compiler,java.desktop`.
351+
352+
For more fine-grained control, you can pass arbitrary filters to JCov using
353+
`--with-jcov-filters`, and you can specify a specific JDK to instrument
354+
using `--with-jcov-input-jdk`.
355+
348356
The JCov report is stored in `build/$BUILD/test-results/jcov-output/report`.
349357

350358
Please note that running with JCov reporting can be very memory intensive.

make/Coverage.gmk

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,28 @@ else
3434
JCOV_INPUT_IMAGE_DIR := $(JDK_IMAGE_DIR)
3535
endif
3636

37+
JCOV_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/jcov
38+
3739
#moving instrumented jdk image in and out of jcov_temp because of CODETOOLS-7902299
38-
JCOV_TEMP := $(SUPPORT_OUTPUTDIR)/jcov_temp
40+
JCOV_TEMP := $(JCOV_SUPPORT_DIR)/temp
41+
42+
ifneq ($(JCOV_MODULES), )
43+
JCOV_MODULES_FILTER := $(foreach m, $(JCOV_MODULES), -include_module $m)
44+
endif
3945

4046
$(JCOV_IMAGE_DIR)/release: $(JCOV_INPUT_IMAGE_DIR)/release
4147
$(call LogWarn, Creating instrumented jdk image with JCov)
4248
$(call MakeDir, $(JCOV_TEMP) $(IMAGES_OUTPUTDIR))
4349
$(RM) -r $(JCOV_IMAGE_DIR) $(JCOV_TEMP)/*
4450
$(CP) -r $(JCOV_INPUT_IMAGE_DIR) $(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR)
45-
$(JAVA) -Xmx3g -jar $(JCOV_HOME)/lib/jcov.jar JREInstr \
51+
$(call ExecuteWithLog, $(JCOV_SUPPORT_DIR)/run-jcov, \
52+
$(JAVA) -Xmx3g -jar $(JCOV_HOME)/lib/jcov.jar JREInstr \
4653
-t $(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR)/template.xml \
4754
-rt $(JCOV_HOME)/lib/jcov_network_saver.jar \
4855
-exclude 'java.lang.Object' \
4956
-exclude jdk.test.Main -exclude '**\$Proxy*' \
50-
$(JCOV_FILTERS) \
51-
$(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR)
57+
$(JCOV_MODULES_FILTER) $(JCOV_FILTERS) \
58+
$(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR))
5259
$(MV) $(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR) $(JCOV_IMAGE_DIR)
5360
$(RMDIR) $(JCOV_TEMP)
5461

make/RunTests.gmk

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ JTREG_COV_OPTIONS :=
115115

116116
ifeq ($(TEST_OPTS_JCOV), true)
117117
JCOV_OUTPUT_DIR := $(TEST_RESULTS_DIR)/jcov-output
118+
JCOV_SUPPORT_DIR := $(TEST_SUPPORT_DIR)/jcov-support
118119
JCOV_GRABBER_LOG := $(JCOV_OUTPUT_DIR)/grabber.log
119120
JCOV_RESULT_FILE := $(JCOV_OUTPUT_DIR)/result.xml
120121
JCOV_REPORT := $(JCOV_OUTPUT_DIR)/report
@@ -1363,18 +1364,23 @@ ifeq ($(TEST_OPTS_JCOV), true)
13631364
$(JAVA) -jar $(JCOV_HOME)/lib/jcov.jar GrabberManager -stop -stoptimeout 3600
13641365

13651366
JCOV_REPORT_TITLE := JDK code coverage report<br/>
1367+
ifneq ($(JCOV_MODULES), )
1368+
JCOV_MODULES_FILTER := $(foreach m, $(JCOV_MODULES), -include_module $m)
1369+
JCOV_REPORT_TITLE += Included modules: $(JCOV_MODULES)<br>
1370+
endif
13661371
ifneq ($(JCOV_FILTERS), )
13671372
JCOV_REPORT_TITLE += Code filters: $(JCOV_FILTERS)<br>
13681373
endif
13691374
JCOV_REPORT_TITLE += Tests: $(TEST)
13701375

13711376
jcov-gen-report: jcov-stop-grabber
13721377
$(call LogWarn, Generating JCov report ...)
1373-
$(JAVA) $(JCOV_VM_OPTS) -jar $(JCOV_HOME)/lib/jcov.jar RepGen -sourcepath \
1378+
$(call ExecuteWithLog, $(JCOV_SUPPORT_DIR)/run-jcov-repgen, \
1379+
$(JAVA) $(JCOV_VM_OPTS) -jar $(JCOV_HOME)/lib/jcov.jar RepGen -sourcepath \
13741380
`$(ECHO) $(TOPDIR)/src/*/share/classes/ | $(TR) ' ' ':'` -fmt html \
1375-
$(JCOV_FILTERS) \
1381+
$(JCOV_MODULES_FILTER) $(JCOV_FILTERS) \
13761382
-mainReportTitle "$(JCOV_REPORT_TITLE)" \
1377-
-o $(JCOV_REPORT) $(JCOV_RESULT_FILE)
1383+
-o $(JCOV_REPORT) $(JCOV_RESULT_FILE))
13781384

13791385
TARGETS += jcov-do-start-grabber jcov-start-grabber jcov-stop-grabber \
13801386
jcov-gen-report

make/autoconf/jdk-options.m4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,19 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
405405
JCOV_FILTERS="$with_jcov_filters"
406406
fi
407407
fi
408+
409+
UTIL_ARG_WITH(NAME: jcov-modules, TYPE: string,
410+
DEFAULT: [], RESULT: JCOV_MODULES_COMMMA_SEPARATED,
411+
DESC: [which modules to include in jcov (comma-separated)],
412+
OPTIONAL: true)
413+
414+
# Replace "," with " ".
415+
JCOV_MODULES=${JCOV_MODULES_COMMMA_SEPARATED//,/ }
408416
AC_SUBST(JCOV_ENABLED)
409417
AC_SUBST(JCOV_HOME)
410418
AC_SUBST(JCOV_INPUT_JDK)
411419
AC_SUBST(JCOV_FILTERS)
420+
AC_SUBST(JCOV_MODULES)
412421
])
413422

414423
################################################################################

make/autoconf/spec.gmk.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -454,6 +454,7 @@ JCOV_ENABLED := @JCOV_ENABLED@
454454
JCOV_HOME := @JCOV_HOME@
455455
JCOV_INPUT_JDK := @JCOV_INPUT_JDK@
456456
JCOV_FILTERS := @JCOV_FILTERS@
457+
JCOV_MODULES := @JCOV_MODULES@
457458

458459
# AddressSanitizer
459460
ASAN_ENABLED := @ASAN_ENABLED@

0 commit comments

Comments
 (0)