Skip to content

Commit 0bc4e7e

Browse files
committed
8292717: Clean up checking of testing requirements in configure
Reviewed-by: clanger Backport-of: 16593cf51c3d994ba4a6d28ab97e519dfd53f37b
1 parent a64639f commit 0bc4e7e

File tree

4 files changed

+176
-174
lines changed

4 files changed

+176
-174
lines changed

make/autoconf/configure.ac

+8-10
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,15 @@ TOOLCHAIN_POST_DETECTION
191191
TOOLCHAIN_SETUP_BUILD_COMPILERS
192192
TOOLCHAIN_MISC_CHECKS
193193

194-
# Setup the JTReg Regression Test Harness.
195-
TOOLCHAIN_SETUP_JTREG
196-
197-
# Setup the Java Microbenchmark Harness (JMH)
198-
LIB_TESTS_SETUP_JMH
199-
200-
# Setup Jib dependency tool
201-
TOOLCHAIN_SETUP_JIB
202-
203194
# After toolchain setup, we need to process some flags to be able to continue.
204195
FLAGS_POST_TOOLCHAIN
205196

197+
# Setup the tools needed to test the JDK (JTReg Regression Test Harness,
198+
# Java Microbenchmark Harness (JMH) and the Jib dependency tool).
199+
LIB_TESTS_SETUP_JTREG
200+
LIB_TESTS_SETUP_JMH
201+
LIB_TESTS_SETUP_JIB
202+
206203
# Now we can test some aspects on the target using configure macros.
207204
PLATFORM_SETUP_OPENJDK_TARGET_BITS
208205
PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS
@@ -244,7 +241,8 @@ HOTSPOT_SETUP_MISC
244241
#
245242
###############################################################################
246243

247-
JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
244+
LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER
245+
248246
JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
249247
JDKOPT_EXCLUDE_TRANSLATIONS
250248
JDKOPT_ENABLE_DISABLE_MANPAGES

make/autoconf/jdk-options.m4

-23
Original file line numberDiff line numberDiff line change
@@ -500,29 +500,6 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
500500
AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
501501
])
502502

503-
################################################################################
504-
#
505-
# Check if building of the jtreg failure handler should be enabled.
506-
#
507-
AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER],
508-
[
509-
UTIL_ARG_ENABLE(NAME: jtreg-failure-handler, DEFAULT: auto,
510-
RESULT: BUILD_FAILURE_HANDLER,
511-
DESC: [enable building of the jtreg failure handler],
512-
DEFAULT_DESC: [enabled if jtreg is present],
513-
CHECKING_MSG: [if the jtreg failure handler should be built],
514-
CHECK_AVAILABLE: [
515-
AC_MSG_CHECKING([if the jtreg failure handler is available])
516-
if test "x$JT_HOME" != "x"; then
517-
AC_MSG_RESULT([yes])
518-
else
519-
AVAILABLE=false
520-
AC_MSG_RESULT([no (jtreg not present)])
521-
fi
522-
])
523-
AC_SUBST(BUILD_FAILURE_HANDLER)
524-
])
525-
526503
################################################################################
527504
#
528505
# Enable or disable generation of the classlist at build time

make/autoconf/lib-tests.m4

+168-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2018, 2022, 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
@@ -23,6 +23,13 @@
2323
# questions.
2424
#
2525

26+
################################################################################
27+
# Setup libraries and functionalities needed to test the JDK.
28+
################################################################################
29+
30+
# Minimum supported version
31+
JTREG_MINIMUM_VERSION=6.1
32+
2633
###############################################################################
2734
#
2835
# Setup and check for gtest framework source files
@@ -118,3 +125,163 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_JMH],
118125
AC_SUBST(JMH_COMMONS_MATH_JAR)
119126
AC_SUBST(JMH_VERSION)
120127
])
128+
129+
# Setup the JTReg Regression Test Harness.
130+
AC_DEFUN_ONCE([LIB_TESTS_SETUP_JTREG],
131+
[
132+
AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
133+
[Regression Test Harness @<:@probed@:>@])])
134+
135+
if test "x$with_jtreg" = xno; then
136+
# jtreg disabled
137+
AC_MSG_CHECKING([for jtreg test harness])
138+
AC_MSG_RESULT([no, disabled])
139+
elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then
140+
if test -d "$with_jtreg"; then
141+
# An explicit path is specified, use it.
142+
JT_HOME="$with_jtreg"
143+
else
144+
case "$with_jtreg" in
145+
*.zip )
146+
JTREG_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/jtreg
147+
$RM -rf $JTREG_SUPPORT_DIR
148+
$MKDIR -p $JTREG_SUPPORT_DIR
149+
$UNZIP -qq -d $JTREG_SUPPORT_DIR $with_jtreg
150+
151+
# Try to find jtreg to determine JT_HOME path
152+
JTREG_PATH=`$FIND $JTREG_SUPPORT_DIR | $GREP "/bin/jtreg"`
153+
if test "x$JTREG_PATH" != x; then
154+
JT_HOME=$($DIRNAME $($DIRNAME $JTREG_PATH))
155+
fi
156+
;;
157+
* )
158+
;;
159+
esac
160+
fi
161+
UTIL_FIXUP_PATH([JT_HOME])
162+
if test ! -d "$JT_HOME"; then
163+
AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist])
164+
fi
165+
166+
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
167+
AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home])
168+
fi
169+
170+
AC_MSG_CHECKING([for jtreg test harness])
171+
AC_MSG_RESULT([$JT_HOME])
172+
else
173+
# Try to locate jtreg using the JT_HOME environment variable
174+
if test "x$JT_HOME" != x; then
175+
# JT_HOME set in environment, use it
176+
if test ! -d "$JT_HOME"; then
177+
AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME])
178+
JT_HOME=
179+
else
180+
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
181+
AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME])
182+
JT_HOME=
183+
else
184+
AC_MSG_NOTICE([Located jtreg using JT_HOME from environment])
185+
fi
186+
fi
187+
fi
188+
189+
if test "x$JT_HOME" = x; then
190+
# JT_HOME is not set in environment, or was deemed invalid.
191+
# Try to find jtreg on path
192+
UTIL_LOOKUP_PROGS(JTREGEXE, jtreg)
193+
if test "x$JTREGEXE" != x; then
194+
# That's good, now try to derive JT_HOME
195+
JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)`
196+
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
197+
AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found])
198+
JT_HOME=
199+
else
200+
AC_MSG_NOTICE([Located jtreg using jtreg executable in path])
201+
fi
202+
fi
203+
fi
204+
205+
AC_MSG_CHECKING([for jtreg test harness])
206+
if test "x$JT_HOME" != x; then
207+
AC_MSG_RESULT([$JT_HOME])
208+
else
209+
AC_MSG_RESULT([no, not found])
210+
211+
if test "x$with_jtreg" = xyes; then
212+
AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.])
213+
fi
214+
fi
215+
fi
216+
217+
UTIL_FIXUP_PATH(JT_HOME)
218+
AC_SUBST(JT_HOME)
219+
220+
# Verify jtreg version
221+
if test "x$JT_HOME" != x; then
222+
AC_MSG_CHECKING([jtreg version number])
223+
# jtreg -version looks like this: "jtreg 6.1+1-19"
224+
# Extract actual version part ("6.1" in this case)
225+
jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2`
226+
jtreg_version=${jtreg_version_full/%+*}
227+
AC_MSG_RESULT([$jtreg_version])
228+
229+
# This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION
230+
comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"`
231+
comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"`
232+
if test $comparable_actual_version -lt $comparable_minimum_version ; then
233+
AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required])
234+
fi
235+
fi
236+
])
237+
238+
# Setup the JIB dependency resolver
239+
AC_DEFUN_ONCE([LIB_TESTS_SETUP_JIB],
240+
[
241+
AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib],
242+
[Jib dependency management tool @<:@not used@:>@])])
243+
244+
if test "x$with_jib" = xno || test "x$with_jib" = x; then
245+
# jib disabled
246+
AC_MSG_CHECKING([for jib])
247+
AC_MSG_RESULT(no)
248+
elif test "x$with_jib" = xyes; then
249+
AC_MSG_ERROR([Must supply a value to --with-jib])
250+
else
251+
JIB_HOME="${with_jib}"
252+
AC_MSG_CHECKING([for jib])
253+
AC_MSG_RESULT(${JIB_HOME})
254+
if test ! -d "${JIB_HOME}"; then
255+
AC_MSG_ERROR([--with-jib must be a directory])
256+
fi
257+
JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar)
258+
if test ! -f "${JIB_JAR}"; then
259+
AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}])
260+
fi
261+
fi
262+
263+
AC_SUBST(JIB_HOME)
264+
])
265+
266+
################################################################################
267+
#
268+
# Check if building of the jtreg failure handler should be enabled.
269+
#
270+
AC_DEFUN_ONCE([LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER],
271+
[
272+
UTIL_ARG_ENABLE(NAME: jtreg-failure-handler, DEFAULT: auto,
273+
RESULT: BUILD_FAILURE_HANDLER,
274+
DESC: [enable building of the jtreg failure handler],
275+
DEFAULT_DESC: [enabled if jtreg is present],
276+
CHECKING_MSG: [if the jtreg failure handler should be built],
277+
CHECK_AVAILABLE: [
278+
AC_MSG_CHECKING([if the jtreg failure handler is available])
279+
if test "x$JT_HOME" != "x"; then
280+
AC_MSG_RESULT([yes])
281+
else
282+
AVAILABLE=false
283+
AC_MSG_RESULT([no (jtreg not present)])
284+
fi
285+
])
286+
AC_SUBST(BUILD_FAILURE_HANDLER)
287+
])

0 commit comments

Comments
 (0)