Skip to content

Commit

Permalink
8245610: remove in-tree copy on gtest
Browse files Browse the repository at this point in the history
Reviewed-by: erikj, ihse
  • Loading branch information
iignatev committed May 26, 2020
1 parent 5374383 commit 846fd23
Show file tree
Hide file tree
Showing 91 changed files with 110 additions and 57,402 deletions.
5 changes: 5 additions & 0 deletions doc/building.html
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@ <h4 id="advanced-make-control-variables">Advanced Make Control Variables</h4>
<h2 id="running-tests">Running Tests</h2>
<p>Most of the JDK tests are using the <a href="http://openjdk.java.net/jtreg">JTReg</a> test framework. Make sure that your configuration knows where to find your installation of JTReg. If this is not picked up automatically, use the <code>--with-jtreg=&lt;path to jtreg home&gt;</code> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing <code>lib/jtreg.jar</code> etc.</p>
<p>The <a href="https://wiki.openjdk.java.net/display/Adoption">Adoption Group</a> provides recent builds of jtreg <a href="https://ci.adoptopenjdk.net/view/Dependencies/job/jtreg/lastSuccessfulBuild/artifact">here</a>. Download the latest <code>.tar.gz</code> file, unpack it, and point <code>--with-jtreg</code> to the <code>jtreg</code> directory that you just unpacked.</p>
<p>Building of Hotspot Gtest suite requires the source code of Google Test framework. The top directory, which contains both <code>googletest</code> and <code>googlemock</code> directories, should be specified via <code>--with-gtest</code>. The supported version of Google Test is 1.8.1, whose source code can be obtained:</p>
<ul>
<li>by downloading and unpacking the source bundle from <a href="https://github.com/google/googletest/releases/tag/release-1.8.1">here</a></li>
<li>or by checking out <code>release-1.8.1</code> tag of <code>googletest</code> project: <code>git clone -b release-1.8.1 https://github.com/google/googletest</code></li>
</ul>
<p>To execute the most basic tests (tier 1), use:</p>
<pre><code>make run-test-tier1</code></pre>
<p>For more details on how to run tests, please see the <a href="testing.html">Testing the JDK</a> document.</p>
Expand Down
8 changes: 8 additions & 0 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,14 @@ https://ci.adoptopenjdk.net/view/Dependencies/job/jtreg/lastSuccessfulBuild/arti
Download the latest `.tar.gz` file, unpack it, and point `--with-jtreg` to the
`jtreg` directory that you just unpacked.
Building of Hotspot Gtest suite requires the source code of Google Test framework.
The top directory, which contains both `googletest` and `googlemock`
directories, should be specified via `--with-gtest`.
The supported version of Google Test is 1.8.1, whose source code can be obtained:
* by downloading and unpacking the source bundle from [here](https://github.com/google/googletest/releases/tag/release-1.8.1)
* or by checking out `release-1.8.1` tag of `googletest` project: `git clone -b release-1.8.1 https://github.com/google/googletest`
To execute the most basic tests (tier 1), use:
```
make run-test-tier1
Expand Down
4 changes: 2 additions & 2 deletions make/Main.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ $(eval $(call SetupTarget, test-image-hotspot-jtreg-graal, \
DEPS := build-test-hotspot-jtreg-graal, \
))

ifeq ($(BUILD_GTEST), true)
ifneq ($GTEST_FRAMEWORK_SRC), )
$(eval $(call SetupTarget, test-image-hotspot-gtest, \
MAKEFILE := hotspot/test/GtestImage, \
DEPS := hotspot, \
Expand Down Expand Up @@ -1109,7 +1109,7 @@ ifneq ($(JVM_TEST_IMAGE_TARGETS), )
test-image: $(JVM_TEST_IMAGE_TARGETS)
else
test-image: test-image-hotspot-jtreg-native
ifeq ($(BUILD_GTEST), true)
ifneq ($(GTEST_FRAMEWORK_SRC), )
test-image: test-image-hotspot-gtest
endif

Expand Down
1 change: 0 additions & 1 deletion make/RunTestsPrebuiltSpec.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ SHELL := $(BASH) $(BASH_ARGS)
# Set some reasonable defaults for features
DEBUG_LEVEL := release
HOTSPOT_DEBUG_LEVEL := release
BUILD_GTEST := true
BUILD_FAILURE_HANDLER := true

################################################################################
Expand Down
3 changes: 0 additions & 3 deletions make/autoconf/buildjdk-spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ DISABLE_WARNING_PREFIX := @BUILD_CC_DISABLE_WARNING_PREFIX@
# Save speed and disk space by not enabling debug symbols for the buildjdk
ENABLE_DEBUG_SYMBOLS := false

# Control whether Hotspot builds gtest tests
BUILD_GTEST := false

JVM_VARIANTS := server
JVM_VARIANT_MAIN := server
JVM_FEATURES_server := cds compiler1 compiler2 g1gc serialgc
Expand Down
1 change: 0 additions & 1 deletion make/autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ LIB_SETUP_LIBRARIES
JVM_FEATURES_PARSE_OPTIONS
JVM_FEATURES_SETUP

HOTSPOT_ENABLE_DISABLE_GTEST
HOTSPOT_SETUP_MISC

###############################################################################
Expand Down
25 changes: 3 additions & 22 deletions make/autoconf/hotspot.m4
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,6 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_VARIANTS],
AC_SUBST(JVM_VARIANT_MAIN)
])

###############################################################################
# Check if gtest should be built
#
AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_GTEST],
[
GTEST_AVAILABLE=true
AC_MSG_CHECKING([if Hotspot gtest test source is present])
if test -e "${TOPDIR}/test/hotspot/gtest"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, cannot build gtest])
GTEST_AVAILABLE=false
fi
UTIL_ARG_ENABLE(NAME: hotspot-gtest, DEFAULT: auto,
RESULT: BUILD_GTEST, AVAILABLE: $GTEST_AVAILABLE,
DEFAULT_DESC: [enabled if possible to build],
DESC: [enable building of the Hotspot unit tests])
AC_SUBST(BUILD_GTEST)
])

###############################################################################
# Misc hotspot setup that does not fit elsewhere.
#
Expand Down Expand Up @@ -162,4 +140,7 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_MISC],
# --with-cpu-port is no longer supported
UTIL_DEPRECATED_ARG_WITH(with-cpu-port)
# in jdk15 hotspot-gtest was replaced with --with-gtest
UTIL_DEPRECATED_ARG_ENABLE(hotspot-gtest)
])
35 changes: 34 additions & 1 deletion make/autoconf/lib-tests.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -55,6 +55,39 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_GRAALUNIT],
AC_SUBST(GRAALUNIT_LIB)
])

###############################################################################
#
# Setup and check for gtest framework source files
#
AC_DEFUN_ONCE([LIB_TESTS_SETUP_GTEST],
[
AC_ARG_WITH(gtest, [AS_HELP_STRING([--with-gtest],
[specify prefix directory for the gtest framework])])
if test "x${with_gtest}" != x; then
AC_MSG_CHECKING([for gtest])
if test "x${with_gtest}" = xno; then
AC_MSG_RESULT([no, disabled])
elif test "x${with_gtest}" = xyes; then
AC_MSG_RESULT([no, error])
AC_MSG_ERROR([--with-gtest must have a value])
else
if ! test -s "${with_gtest}/googletest/include/gtest/gtest.h"; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([Can't find 'googletest/include/gtest/gtest.h' under ${with_gtest} given with the --with-gtest option.])
elif ! test -s "${with_gtest}/googlemock/include/gmock/gmock.h"; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([Can't find 'googlemock/include/gmock/gmock.h' under ${with_gtest} given with the --with-gtest option.])
else
GTEST_FRAMEWORK_SRC=${with_gtest}
AC_MSG_RESULT([$GTEST_FRAMEWORK_SRC])
fi
fi
fi
AC_SUBST(GTEST_FRAMEWORK_SRC)
])

###############################################################################
#
# Setup and check the Java Microbenchmark Harness
Expand Down
1 change: 1 addition & 0 deletions make/autoconf/libraries.m4
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
LIB_SETUP_BUNDLED_LIBS
LIB_SETUP_MISC_LIBS
LIB_TESTS_SETUP_GRAALUNIT
LIB_TESTS_SETUP_GTEST
BASIC_JDKLIB_LIBS=""
if test "x$TOOLCHAIN_TYPE" != xmicrosoft; then
Expand Down
5 changes: 2 additions & 3 deletions make/autoconf/spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,6 @@ JVM_FEATURES_custom := @JVM_FEATURES_custom@
VALID_JVM_FEATURES := @VALID_JVM_FEATURES@
VALID_JVM_VARIANTS := @VALID_JVM_VARIANTS@

# Control whether Hotspot builds gtest tests
BUILD_GTEST := @BUILD_GTEST@

# Allow overriding the default hotspot library path
HOTSPOT_OVERRIDE_LIBPATH := @HOTSPOT_OVERRIDE_LIBPATH@

Expand Down Expand Up @@ -392,6 +389,8 @@ JMH_JOPT_SIMPLE_JAR := @JMH_JOPT_SIMPLE_JAR@
JMH_COMMONS_MATH_JAR := @JMH_COMMONS_MATH_JAR@
JMH_VERSION := @JMH_VERSION@

GTEST_FRAMEWORK_SRC := @GTEST_FRAMEWORK_SRC@

# Source file for cacerts
CACERTS_FILE=@CACERTS_FILE@

Expand Down
30 changes: 18 additions & 12 deletions make/conf/jib-profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ var getJibProfilesProfiles = function (input, common, data) {
"linux-x64": {
target_os: "linux",
target_cpu: "x64",
dependencies: ["devkit", "graphviz", "pandoc", "graalunit_lib"],
dependencies: ["devkit", "gtest", "graphviz", "pandoc", "graalunit_lib"],
configure_args: concat(common.configure_args_64bit,
"--enable-full-docs", "--with-zlib=system",
(isWsl(input) ? [ "--host=x86_64-unknown-linux-gnu",
Expand All @@ -416,39 +416,39 @@ var getJibProfilesProfiles = function (input, common, data) {
target_os: "linux",
target_cpu: "x86",
build_cpu: "x64",
dependencies: ["devkit"],
dependencies: ["devkit", "gtest"],
configure_args: concat(common.configure_args_32bit,
"--with-jvm-variants=minimal,server", "--with-zlib=system"),
},

"macosx-x64": {
target_os: "macosx",
target_cpu: "x64",
dependencies: ["devkit", "pandoc", "graalunit_lib"],
dependencies: ["devkit", "gtest", "pandoc", "graalunit_lib"],
configure_args: concat(common.configure_args_64bit, "--with-zlib=system",
"--with-macosx-version-max=10.9.0"),
},

"windows-x64": {
target_os: "windows",
target_cpu: "x64",
dependencies: ["devkit", "pandoc", "graalunit_lib"],
dependencies: ["devkit", "gtest", "pandoc", "graalunit_lib"],
configure_args: concat(common.configure_args_64bit),
},

"windows-x86": {
target_os: "windows",
target_cpu: "x86",
build_cpu: "x64",
dependencies: ["devkit"],
dependencies: ["devkit", "gtest"],
configure_args: concat(common.configure_args_32bit),
},

"linux-aarch64": {
target_os: "linux",
target_cpu: "aarch64",
build_cpu: "x64",
dependencies: ["devkit", "build_devkit", "pandoc"],
dependencies: ["devkit", "gtest", "build_devkit", "pandoc"],
configure_args: [
"--openjdk-target=aarch64-linux-gnu",
"--disable-jvm-feature-jvmci",
Expand All @@ -461,7 +461,7 @@ var getJibProfilesProfiles = function (input, common, data) {
target_os: "linux",
target_cpu: "arm",
build_cpu: "x64",
dependencies: ["devkit", "build_devkit"],
dependencies: ["devkit", "gtest", "build_devkit"],
configure_args: [
"--openjdk-target=arm-linux-gnueabihf", "--with-freetype=bundled",
"--with-abi-profile=arm-vfp-hflt", "--disable-warnings-as-errors"
Expand All @@ -472,7 +472,7 @@ var getJibProfilesProfiles = function (input, common, data) {
target_os: "linux",
target_cpu: "ppc64le",
build_cpu: "x64",
dependencies: ["devkit", "build_devkit"],
dependencies: ["devkit", "gtest", "build_devkit"],
configure_args: [
"--openjdk-target=ppc64le-linux-gnu", "--with-freetype=bundled",
"--disable-warnings-as-errors"
Expand All @@ -483,7 +483,7 @@ var getJibProfilesProfiles = function (input, common, data) {
target_os: "linux",
target_cpu: "s390x",
build_cpu: "x64",
dependencies: ["devkit", "build_devkit"],
dependencies: ["devkit", "gtest", "build_devkit"],
configure_args: [
"--openjdk-target=s390x-linux-gnu", "--with-freetype=bundled",
"--disable-warnings-as-errors"
Expand Down Expand Up @@ -538,7 +538,7 @@ var getJibProfilesProfiles = function (input, common, data) {
"linux-x64-zero": {
target_os: "linux",
target_cpu: "x64",
dependencies: ["devkit"],
dependencies: ["devkit", "gtest"],
configure_args: concat(common.configure_args_64bit, [
"--with-zlib=system",
"--with-jvm-variants=zero",
Expand All @@ -550,7 +550,7 @@ var getJibProfilesProfiles = function (input, common, data) {
target_os: "linux",
target_cpu: "x86",
build_cpu: "x64",
dependencies: ["devkit"],
dependencies: ["devkit", "gtest"],
configure_args: concat(common.configure_args_32bit, [
"--with-zlib=system",
"--with-jvm-variants=zero",
Expand All @@ -573,7 +573,7 @@ var getJibProfilesProfiles = function (input, common, data) {
"linux-x64-debug-nopch": {
target_os: "linux",
target_cpu: "x64",
dependencies: ["devkit"],
dependencies: ["devkit", "gtest"],
configure_args: concat(common.configure_args_64bit,
"--with-zlib=system", "--disable-precompiled-headers"),
},
Expand Down Expand Up @@ -1148,6 +1148,12 @@ var getJibProfilesDependencies = function (input, common) {
configure_args: "--with-graalunit-lib=" + input.get("graalunit_lib", "install_path"),
environment_name: "GRAALUNIT_LIB"
},

gtest: {
organization: common.organization,
ext: "tar.gz",
revision: "1.8.1"
},
};

return dependencies;
Expand Down
43 changes: 36 additions & 7 deletions make/hotspot/lib/CompileGtest.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ $(eval $(call IncludeCustomExtension, hotspot/lib/CompileGtest.gmk))

GTEST_TEST_SRC += $(TOPDIR)/test/hotspot/gtest
GTEST_LAUNCHER_SRC := $(TOPDIR)/test/hotspot/gtest/gtestLauncher.cpp
GTEST_FRAMEWORK_SRC := $(TOPDIR)/test/fmw/gtest

# On Windows, there are no internal debug symbols so must set copying to true
# to get any at all.
Expand All @@ -39,6 +38,36 @@ endif

################################################################################

# Disabling all warnings in gtest source code

$(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBGTEST, \
NAME := gtest, \
TYPE := STATIC_LIBRARY, \
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
OUTPUT_DIR := $(JVM_OUTPUTDIR)/libgtest, \
OBJECT_DIR := $(JVM_OUTPUTDIR)/libgtest/objs, \
SRC := \
$(GTEST_FRAMEWORK_SRC)/googletest/src \
$(GTEST_FRAMEWORK_SRC)/googlemock/src, \
INCLUDE_FILES := gtest-all.cc gmock-all.cc, \
CFLAGS := $(filter-out $(WARNING_CFLAGS_JVM), $(JVM_CFLAGS)) \
-w \
-I$(GTEST_FRAMEWORK_SRC)/googletest \
-I$(GTEST_FRAMEWORK_SRC)/googletest/include \
-I$(GTEST_FRAMEWORK_SRC)/googlemock \
-I$(GTEST_FRAMEWORK_SRC)/googlemock/include, \
CFLAGS_windows := -EHsc, \
CFLAGS_macosx := -DGTEST_OS_MAC=1, \
OPTIMIZATION := $(JVM_OPTIMIZATION), \
COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \
ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \
STRIP_SYMBOLS := false, \
))

TARGETS += $(BUILD_GTEST_LIBGTEST)

################################################################################

ifeq ($(call isTargetOs, windows), true)
GTEST_JVM_MAPFILE := $(JVM_MAPFILE)
else
Expand All @@ -64,15 +93,10 @@ $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \
EXCLUDES := $(JVM_EXCLUDES), \
EXCLUDE_FILES := gtestLauncher.cpp, \
EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
EXTRA_FILES := \
$(GTEST_FRAMEWORK_SRC)/googletest/src/gtest-all.cc \
$(GTEST_FRAMEWORK_SRC)/googlemock/src/gmock-all.cc, \
EXTRA_OBJECT_FILES := $(filter-out %/operator_new$(OBJ_SUFFIX), \
$(BUILD_LIBJVM_ALL_OBJS)), \
CFLAGS := $(JVM_CFLAGS) \
-I$(GTEST_FRAMEWORK_SRC)/googletest \
-I$(GTEST_FRAMEWORK_SRC)/googletest/include \
-I$(GTEST_FRAMEWORK_SRC)/googlemock \
-I$(GTEST_FRAMEWORK_SRC)/googlemock/include \
$(addprefix -I,$(GTEST_TEST_SRC)), \
CFLAGS_windows := -EHsc, \
Expand All @@ -83,17 +107,22 @@ $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \
undef switch format-nonliteral tautological-undefined-compare \
self-assign-overloaded, \
LDFLAGS := $(JVM_LDFLAGS), \
LDFLAGS_unix := -L$(JVM_OUTPUTDIR)/libgtest, \
LIBS := $(JVM_LIBS), \
LIBS_unix := -lgtest, \
LIBS_windows := $(JVM_OUTPUTDIR)/libgtest/gtest.lib, \
OPTIMIZATION := $(JVM_OPTIMIZATION), \
MAPFILE := $(GTEST_JVM_MAPFILE), \
USE_MAPFILE_FOR_SYMBOLS := true, \
COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \
ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \
STRIP_SYMBOLS := false, \
PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
PRECOMPILED_HEADER_EXCLUDE := gtest-all.cc gmock-all.cc gtestMain.cpp, \
PRECOMPILED_HEADER_EXCLUDE := gtestMain.cpp, \
))

$(BUILD_GTEST_LIBJVM) : $(BUILD_GTEST_LIBGTEST)

TARGETS += $(BUILD_GTEST_LIBJVM)

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion make/hotspot/lib/CompileLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ include HotspotCommon.gmk

include lib/CompileJvm.gmk

ifeq ($(BUILD_GTEST), true)
ifneq ($(GTEST_FRAMEWORK_SRC), )
include lib/CompileGtest.gmk
endif

Expand Down
Loading

0 comments on commit 846fd23

Please sign in to comment.