2
# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation. Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
26
################################################################################
27
# Setup libraries and functionalities needed to test the JDK.
28
################################################################################
30
# Minimum supported versions
31
JTREG_MINIMUM_VERSION=7.4
32
GTEST_MINIMUM_VERSION=1.14.0
34
###############################################################################
36
# Setup and check for gtest framework source files
38
AC_DEFUN_ONCE([LIB_TESTS_SETUP_GTEST],
40
AC_ARG_WITH(gtest, [AS_HELP_STRING([--with-gtest],
41
[specify prefix directory for the gtest framework])])
43
if test "x${with_gtest}" != x; then
44
AC_MSG_CHECKING([for gtest])
45
if test "x${with_gtest}" = xno; then
46
AC_MSG_RESULT([no, disabled])
47
elif test "x${with_gtest}" = xyes; then
48
AC_MSG_RESULT([no, error])
49
AC_MSG_ERROR([--with-gtest must have a value])
51
if ! test -s "${with_gtest}/googletest/include/gtest/gtest.h"; then
53
AC_MSG_ERROR([Can't find 'googletest/include/gtest/gtest.h' under ${with_gtest} given with the --with-gtest option.])
54
elif ! test -s "${with_gtest}/googlemock/include/gmock/gmock.h"; then
56
AC_MSG_ERROR([Can't find 'googlemock/include/gmock/gmock.h' under ${with_gtest} given with the --with-gtest option.])
58
GTEST_FRAMEWORK_SRC=$with_gtest
59
AC_MSG_RESULT([$GTEST_FRAMEWORK_SRC])
60
UTIL_FIXUP_PATH([GTEST_FRAMEWORK_SRC])
62
# Verify that the version is the required one.
63
# This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION
64
gtest_version="`$GREP GOOGLETEST_VERSION $GTEST_FRAMEWORK_SRC/CMakeLists.txt | $SED -e 's/set(GOOGLETEST_VERSION \(.*\))/\1/'`"
65
comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$gtest_version"`
66
comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$GTEST_MINIMUM_VERSION"`
67
if test $comparable_actual_version -lt $comparable_minimum_version ; then
68
AC_MSG_ERROR([gtest version is too old, at least version $GTEST_MINIMUM_VERSION is required])
74
AC_SUBST(GTEST_FRAMEWORK_SRC)
77
###############################################################################
79
# Setup and check the Java Microbenchmark Harness
81
AC_DEFUN_ONCE([LIB_TESTS_SETUP_JMH],
83
AC_ARG_WITH(jmh, [AS_HELP_STRING([--with-jmh],
84
[Java Microbenchmark Harness for building the OpenJDK Microbenchmark Suite])])
86
AC_MSG_CHECKING([for jmh (Java Microbenchmark Harness)])
87
if test "x$with_jmh" = xno || test "x$with_jmh" = x; then
88
AC_MSG_RESULT([no, disabled])
89
elif test "x$with_jmh" = xyes; then
90
AC_MSG_RESULT([no, error])
91
AC_MSG_ERROR([--with-jmh requires a directory containing all jars needed by JMH])
95
if test ! -d [$JMH_HOME]; then
96
AC_MSG_RESULT([no, error])
97
AC_MSG_ERROR([$JMH_HOME does not exist or is not a directory])
99
AC_MSG_RESULT([yes, $JMH_HOME])
101
UTIL_FIXUP_PATH([JMH_HOME])
103
jar_names="jmh-core jmh-generator-annprocess jopt-simple commons-math3"
104
for jar in $jar_names; do
105
found_jar_files=$($ECHO $(ls $JMH_HOME/$jar-*.jar 2> /dev/null))
107
if test "x$found_jar_files" = x; then
108
AC_MSG_ERROR([--with-jmh does not contain $jar-*.jar])
109
elif ! test -e "$found_jar_files"; then
110
AC_MSG_ERROR([--with-jmh contain multiple $jar-*.jar: $found_jar_files])
113
found_jar_var_name=found_${jar//-/_}
114
eval $found_jar_var_name='"'$found_jar_files'"'
117
JMH_CORE_JAR=$found_jmh_core
118
JMH_GENERATOR_JAR=$found_jmh_generator_annprocess
119
JMH_JOPT_SIMPLE_JAR=$found_jopt_simple
120
JMH_COMMONS_MATH_JAR=$found_commons_math3
123
if [ [[ "$JMH_CORE_JAR" =~ jmh-core-(.*)\.jar$ ]] ] ; then
124
JMH_VERSION=${BASH_REMATCH[[1]]}
129
AC_MSG_NOTICE([JMH core version: $JMH_VERSION])
132
AC_SUBST(JMH_CORE_JAR)
133
AC_SUBST(JMH_GENERATOR_JAR)
134
AC_SUBST(JMH_JOPT_SIMPLE_JAR)
135
AC_SUBST(JMH_COMMONS_MATH_JAR)
136
AC_SUBST(JMH_VERSION)
139
# Setup the JTReg Regression Test Harness.
140
AC_DEFUN_ONCE([LIB_TESTS_SETUP_JTREG],
142
AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
143
[Regression Test Harness @<:@probed@:>@])])
145
if test "x$with_jtreg" = xno; then
147
AC_MSG_CHECKING([for jtreg test harness])
148
AC_MSG_RESULT([no, disabled])
149
elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then
150
if test -d "$with_jtreg"; then
151
# An explicit path is specified, use it.
152
JT_HOME="$with_jtreg"
154
case "$with_jtreg" in
156
JTREG_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/jtreg
157
$RM -rf $JTREG_SUPPORT_DIR
158
$MKDIR -p $JTREG_SUPPORT_DIR
159
$UNZIP -qq -d $JTREG_SUPPORT_DIR $with_jtreg
161
# Try to find jtreg to determine JT_HOME path
162
JTREG_PATH=`$FIND $JTREG_SUPPORT_DIR | $GREP "/bin/jtreg"`
163
if test "x$JTREG_PATH" != x; then
164
JT_HOME=$($DIRNAME $($DIRNAME $JTREG_PATH))
171
UTIL_FIXUP_PATH([JT_HOME])
172
if test ! -d "$JT_HOME"; then
173
AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist])
176
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
177
AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home])
180
AC_MSG_CHECKING([for jtreg test harness])
181
AC_MSG_RESULT([$JT_HOME])
183
# Try to locate jtreg using the JT_HOME environment variable
184
if test "x$JT_HOME" != x; then
185
# JT_HOME set in environment, use it
186
if test ! -d "$JT_HOME"; then
187
AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME])
190
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
191
AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME])
194
AC_MSG_NOTICE([Located jtreg using JT_HOME from environment])
199
if test "x$JT_HOME" = x; then
200
# JT_HOME is not set in environment, or was deemed invalid.
201
# Try to find jtreg on path
202
UTIL_LOOKUP_PROGS(JTREGEXE, jtreg)
203
if test "x$JTREGEXE" != x; then
204
# That's good, now try to derive JT_HOME
205
JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)`
206
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
207
AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found])
210
AC_MSG_NOTICE([Located jtreg using jtreg executable in path])
215
AC_MSG_CHECKING([for jtreg test harness])
216
if test "x$JT_HOME" != x; then
217
AC_MSG_RESULT([$JT_HOME])
219
AC_MSG_RESULT([no, not found])
221
if test "x$with_jtreg" = xyes; then
222
AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.])
227
UTIL_FIXUP_PATH(JT_HOME)
230
# Specify a JDK for running jtreg. Defaults to the BOOT_JDK.
231
AC_ARG_WITH(jtreg-jdk, [AS_HELP_STRING([--with-jdk],
232
[path to JDK for running jtreg @<:@BOOT_JDK@:>@])])
234
AC_MSG_CHECKING([for jtreg jdk])
235
if test "x${with_jtreg_jdk}" != x; then
236
if test "x${with_jtreg_jdk}" = xno; then
237
AC_MSG_RESULT([no, jtreg jdk not specified])
238
elif test "x${with_jtreg_jdk}" = xyes; then
239
AC_MSG_RESULT([not specified])
240
AC_MSG_ERROR([--with-jtreg-jdk needs a value])
242
JTREG_JDK="${with_jtreg_jdk}"
243
AC_MSG_RESULT([$JTREG_JDK])
244
UTIL_FIXUP_PATH(JTREG_JDK)
245
if test ! -f "$JTREG_JDK/bin/java"; then
246
AC_MSG_ERROR([Could not find jtreg java at $JTREG_JDK/bin/java])
250
JTREG_JDK="${BOOT_JDK}"
251
AC_MSG_RESULT([no, using BOOT_JDK])
254
UTIL_FIXUP_PATH(JTREG_JDK)
255
AC_SUBST([JTREG_JDK])
256
# For use in the configure script
257
JTREG_JAVA="$FIXPATH $JTREG_JDK/bin/java"
259
# Verify jtreg version
260
if test "x$JT_HOME" != x; then
261
AC_MSG_CHECKING([jtreg jar existence])
262
if test ! -f "$JT_HOME/lib/jtreg.jar"; then
263
AC_MSG_ERROR([Could not find jtreg jar at $JT_HOME/lib/jtreg.jar])
266
AC_MSG_CHECKING([jtreg version number])
267
# jtreg -version looks like this: "jtreg 6.1+1-19"
268
# Extract actual version part ("6.1" in this case)
269
jtreg_version_full=$($JTREG_JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2)
271
jtreg_version=${jtreg_version_full/%+*}
272
AC_MSG_RESULT([$jtreg_version])
274
# This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION
275
comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"`
276
comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"`
277
if test $comparable_actual_version -lt $comparable_minimum_version ; then
278
AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required])
283
# Setup the JIB dependency resolver
284
AC_DEFUN_ONCE([LIB_TESTS_SETUP_JIB],
286
AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib],
287
[Jib dependency management tool @<:@not used@:>@])])
289
if test "x$with_jib" = xno || test "x$with_jib" = x; then
291
AC_MSG_CHECKING([for jib])
293
elif test "x$with_jib" = xyes; then
294
AC_MSG_ERROR([Must supply a value to --with-jib])
296
JIB_HOME="${with_jib}"
297
AC_MSG_CHECKING([for jib])
298
AC_MSG_RESULT(${JIB_HOME})
299
if test ! -d "${JIB_HOME}"; then
300
AC_MSG_ERROR([--with-jib must be a directory])
302
JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar)
303
if test ! -f "${JIB_JAR}"; then
304
AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}])
311
################################################################################
313
# Check if building of the jtreg failure handler should be enabled.
315
AC_DEFUN_ONCE([LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER],
317
if test "x$BUILD_ENV" = "xci"; then
318
BUILD_FAILURE_HANDLER_DEFAULT=auto
320
BUILD_FAILURE_HANDLER_DEFAULT=false
323
UTIL_ARG_ENABLE(NAME: jtreg-failure-handler, DEFAULT: $BUILD_FAILURE_HANDLER_DEFAULT,
324
RESULT: BUILD_FAILURE_HANDLER,
325
DESC: [enable building of the jtreg failure handler],
326
DEFAULT_DESC: [enabled if jtreg is present and build env is CI],
327
CHECKING_MSG: [if the jtreg failure handler should be built],
329
AC_MSG_CHECKING([if the jtreg failure handler is available])
330
if test "x$JT_HOME" != "x"; then
334
AC_MSG_RESULT([no (jtreg not present)])
337
AC_SUBST(BUILD_FAILURE_HANDLER)
340
AC_DEFUN_ONCE([LIB_TESTS_ENABLE_DISABLE_JTREG_TEST_THREAD_FACTORY],
342
UTIL_ARG_ENABLE(NAME: jtreg-test-thread-factory, DEFAULT: auto,
343
RESULT: BUILD_JTREG_TEST_THREAD_FACTORY,
344
DESC: [enable building of the jtreg test thread factory],
345
DEFAULT_DESC: [enabled if jtreg is present],
346
CHECKING_MSG: [if the jtreg test thread factory should be built],
348
AC_MSG_CHECKING([if the jtreg test thread factory is available])
349
if test "x$JT_HOME" != "x"; then
353
AC_MSG_RESULT([no (jtreg not present)])
356
AC_SUBST(BUILD_JTREG_TEST_THREAD_FACTORY)