8219395: integrate gcov w/ run-test

Reviewed-by: erikj
This commit is contained in:
Igor Ignatyev 2019-02-20 11:32:53 -08:00
parent 9d263d4bc1
commit 6559dfbda0
3 changed files with 63 additions and 6 deletions

View File

@ -112,6 +112,9 @@ GTEST_LAUNCHER_DIRS := $(patsubst %/gtestLauncher, %, \
GTEST_VARIANTS := $(strip $(patsubst $(TEST_IMAGE_DIR)/hotspot/gtest/%, %, \
$(GTEST_LAUNCHER_DIRS)))
COV_ENVIRONMENT :=
JTREG_COV_OPTIONS :=
ifeq ($(TEST_OPTS_JCOV), true)
JCOV_OUTPUT_DIR := $(TEST_RESULTS_DIR)/jcov-output
JCOV_GRABBER_LOG := $(JCOV_OUTPUT_DIR)/grabber.log
@ -122,12 +125,18 @@ ifeq ($(TEST_OPTS_JCOV), true)
# Replace our normal test JDK with the JCov image.
JDK_UNDER_TEST := $(JCOV_IMAGE_DIR)
JCOV_ENVIRONMENT := JAVA_TOOL_OPTIONS="$(JCOV_MEM_OPTIONS)" \
COV_ENVIRONMENT += JAVA_TOOL_OPTIONS="$(JCOV_MEM_OPTIONS)" \
_JAVA_OPTIONS="$(JCOV_MEM_OPTIONS)"
JTREG_JCOV_OPTIONS := -e:JAVA_TOOL_OPTIONS='$(JCOV_MEM_OPTIONS)' \
JTREG_COV_OPTIONS += -e:JAVA_TOOL_OPTIONS='$(JCOV_MEM_OPTIONS)' \
-e:_JAVA_OPTIONS='$(JCOV_MEM_OPTIONS)'
endif
ifeq ($(GCOV_ENABLED), true)
GCOV_OUTPUT_DIR := $(TEST_RESULTS_DIR)/gcov-output
COV_ENVIRONMENT += GCOV_PREFIX="$(GCOV_OUTPUT_DIR)"
JTREG_COV_OPTIONS += -e:GCOV_PREFIX="$(GCOV_OUTPUT_DIR)"
endif
################################################################################
# Optionally create AOT libraries for specified modules before running tests.
# Note, this could not be done during JDK build time.
@ -170,6 +179,7 @@ define SetupAotModuleBody
$$(call LogWarn, Generating $$(patsubst $$(OUTPUTDIR)/%, %, $$@))
$$(call MakeTargetDir)
$$(call ExecuteWithLog, $$@, \
$((COV_ENVIRONMENT) \
$$(FIXPATH) $$(JDK_UNDER_TEST)/bin/jaotc \
$$($1_JAOTC_OPTS) --output $$@ --module $$($1_MODULE) \
)
@ -907,7 +917,7 @@ define SetupRunJtregTestBody
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, \
$$(JCOV_ENVIRONMENT) \
$$(COV_ENVIRONMENT) \
$$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \
-Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \
$$($1_JTREG_BASIC_OPTIONS) \
@ -917,7 +927,7 @@ define SetupRunJtregTestBody
-workDir:$$($1_TEST_SUPPORT_DIR) \
$$(JTREG_OPTIONS) \
$$(JTREG_FAILURE_HANDLER_OPTIONS) \
$$(JTREG_JCOV_OPTIONS) \
$$(JTREG_COV_OPTIONS) \
$$($1_TEST_NAME) \
&& $$(ECHO) $$$$? > $$($1_EXITCODE) \
|| $$(ECHO) $$$$? > $$($1_EXITCODE) \

View File

@ -364,7 +364,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
################################################################################
#
# Gcov coverage data for hotspot
# Native and Java code coverage
#
AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
[

View File

@ -521,6 +521,15 @@ var getJibProfilesProfiles = function (input, common, data) {
profiles[maketestName].default_make_targets = [ "test-make" ];
});
// Generate -gcov profiles
[ "linux-x64", "macosx-x64" ].forEach(function (name) {
var gcovName = name + "-gcov";
profiles[gcovName] = clone(profiles[name]);
profiles[gcovName].default_make_targets = ["product-bundles", "test-bundles"];
profiles[gcovName].configure_args = concat(profiles[gcovName].configure_args,
["--enable-native-coverage", "--disable-warnings-as-errors"]);
});
// Profiles for building the zero jvm variant. These are used for verification.
var zeroProfiles = {
"linux-x64-zero": {
@ -772,6 +781,40 @@ var getJibProfilesProfiles = function (input, common, data) {
};
});
// Artifacts of gcov (native-code-coverage) profiles
[ "linux-x64", "macosx-x64" ].forEach(function (name) {
var o = artifactData[name]
var pf = o.platform
var jdk_subdir = (o.jdk_subdir != null ? o.jdk_subdir : "jdk-" + data.version);
var jdk_suffix = (o.jdk_suffix != null ? o.jdk_suffix : "tar.gz");
var gcovName = name + "-gcov";
profiles[gcovName].artifacts = {
jdk: {
local: "bundles/\\(jdk.*bin." + jdk_suffix + "\\)",
remote: [
"bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-gcov." + jdk_suffix,
],
subdir: jdk_subdir,
exploded: "images/jdk",
},
test: {
local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
remote: [
"bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-gcov-tests.tar.gz",
],
exploded: "images/test"
},
jdk_symbols: {
local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
remote: [
"bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-gcov-symbols.tar.gz",
],
subdir: jdk_subdir,
exploded: "images/jdk"
},
};
});
// Profiles used to run tests.
var testOnlyProfiles = {
"run-test": {
@ -798,6 +841,10 @@ var getJibProfilesProfiles = function (input, common, data) {
} else {
testedProfileTest = testedProfile + ".test";
}
var testOnlyMake = [ "run-test-prebuilt", "LOG_CMDLINES=true", "JTREG_VERBOSE=fail,error,time" ];
if (testedProfile.endsWith("-gcov")) {
testOnlyMake = concat(testOnlyMake, "GCOV_ENABLED=true")
}
var testOnlyProfilesPrebuilt = {
"run-test-prebuilt": {
target_os: input.build_os,
@ -807,7 +854,7 @@ var getJibProfilesProfiles = function (input, common, data) {
testedProfileTest
],
src: "src.conf",
make_args: [ "run-test-prebuilt", "LOG_CMDLINES=true", "JTREG_VERBOSE=fail,error,time" ],
make_args: testOnlyMake,
environment: {
"BOOT_JDK": common.boot_jdk_home,
"JDK_IMAGE_DIR": input.get(testedProfileJDK, "home_path"),