# HG changeset patch # User iignatyev # Date 1550623779 28800 # Tue Feb 19 16:49:39 2019 -0800 # Node ID 3f7c416cb1409b64eb54d9991c5f70f252c322cc # Parent 1e569f37cf3620cc283c532a80fdf397beb11e46 8219395: integrate gcov w/ run-test Reviewed-by: duke diff --git a/make/RunTests.gmk b/make/RunTests.gmk --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -112,6 +112,9 @@ 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 @@ # 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 @@ $$(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 @@ $$(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 @@ -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) \ diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -364,7 +364,7 @@ ################################################################################ # -# Gcov coverage data for hotspot +# Native and Java code coverage # AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE], [ diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -521,6 +521,14 @@ 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].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 +780,43 @@ }; }); + // 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, + // "bundles/" + pf + "/\\1" + ], + 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", + // "bundles/" + pf + "/\\1" + ], + exploded: "images/test" + }, + jdk_symbols: { + local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)", + remote: [ + "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-gcov-symbols.tar.gz", + // "bundles/" + pf + "/\\1" + ], + subdir: jdk_subdir, + exploded: "images/jdk" + }, + }; + }); + // Profiles used to run tests. var testOnlyProfiles = { "run-test": { @@ -798,6 +843,10 @@ } 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 +856,7 @@ 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"),