Skip to content

Commit cb1b9a6

Browse files
committed
8292717: Clean up checking of testing requirements in configure
Reviewed-by: shade, mdoerr Backport-of: 16593cf51c3d994ba4a6d28ab97e519dfd53f37b
1 parent 7ed3c3e commit cb1b9a6

File tree

4 files changed

+185
-181
lines changed

4 files changed

+185
-181
lines changed

make/autoconf/configure.ac

+7-7
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,14 @@ TOOLCHAIN_POST_DETECTION
183183
TOOLCHAIN_SETUP_BUILD_COMPILERS
184184
TOOLCHAIN_MISC_CHECKS
185185

186-
# Setup the JTReg Regression Test Harness.
187-
TOOLCHAIN_SETUP_JTREG
188-
189-
# Setup Jib dependency tool
190-
TOOLCHAIN_SETUP_JIB
191-
192186
# After toolchain setup, we need to process some flags to be able to continue.
193187
FLAGS_POST_TOOLCHAIN
194188

189+
# Setup the tools needed to test the JDK (JTReg Regression Test Harness
190+
# and the Jib dependency tool).
191+
LIB_TESTS_SETUP_JTREG
192+
LIB_TESTS_SETUP_JIB
193+
195194
# Now we can test some aspects on the target using configure macros.
196195
PLATFORM_SETUP_OPENJDK_TARGET_BITS
197196
PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS
@@ -233,7 +232,8 @@ HOTSPOT_SETUP_JVM_FEATURES
233232
###############################################################################
234233

235234
JDKOPT_DETECT_INTREE_EC
236-
JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
235+
LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER
236+
237237
JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
238238
JDKOPT_EXCLUDE_TRANSLATIONS
239239
JDKOPT_ENABLE_DISABLE_MANPAGES

make/autoconf/jdk-options.m4

-39
Original file line numberDiff line numberDiff line change
@@ -521,45 +521,6 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
521521
AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
522522
])
523523

524-
################################################################################
525-
#
526-
# Check if building of the jtreg failure handler should be enabled.
527-
#
528-
AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER],
529-
[
530-
AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
531-
[forces build of the jtreg failure handler to be enabled, missing dependencies
532-
become fatal errors. Default is auto, where the failure handler is built if all
533-
dependencies are present and otherwise just disabled.])])
534-
535-
AC_MSG_CHECKING([if jtreg failure handler should be built])
536-
537-
if test "x$enable_jtreg_failure_handler" = "xyes"; then
538-
if test "x$JT_HOME" = "x"; then
539-
AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
540-
else
541-
BUILD_FAILURE_HANDLER=true
542-
AC_MSG_RESULT([yes, forced])
543-
fi
544-
elif test "x$enable_jtreg_failure_handler" = "xno"; then
545-
BUILD_FAILURE_HANDLER=false
546-
AC_MSG_RESULT([no, forced])
547-
elif test "x$enable_jtreg_failure_handler" = "xauto" \
548-
|| test "x$enable_jtreg_failure_handler" = "x"; then
549-
if test "x$JT_HOME" = "x"; then
550-
BUILD_FAILURE_HANDLER=false
551-
AC_MSG_RESULT([no, missing jtreg])
552-
else
553-
BUILD_FAILURE_HANDLER=true
554-
AC_MSG_RESULT([yes, jtreg present])
555-
fi
556-
else
557-
AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
558-
fi
559-
560-
AC_SUBST(BUILD_FAILURE_HANDLER)
561-
])
562-
563524
################################################################################
564525
#
565526
# Enable or disable generation of the classlist at build time

make/autoconf/lib-tests.m4

+178-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2018, 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
# Check for graalunit libs, needed for running graalunit tests.
@@ -54,3 +61,173 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_GRAALUNIT],
5461
UTIL_FIXUP_PATH([GRAALUNIT_LIB])
5562
AC_SUBST(GRAALUNIT_LIB)
5663
])
64+
65+
# Setup the JTReg Regression Test Harness.
66+
AC_DEFUN_ONCE([LIB_TESTS_SETUP_JTREG],
67+
[
68+
AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
69+
[Regression Test Harness @<:@probed@:>@])])
70+
71+
if test "x$with_jtreg" = xno; then
72+
# jtreg disabled
73+
AC_MSG_CHECKING([for jtreg test harness])
74+
AC_MSG_RESULT([no, disabled])
75+
elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then
76+
# An explicit path is specified, use it.
77+
JT_HOME="$with_jtreg"
78+
UTIL_FIXUP_PATH([JT_HOME])
79+
if test ! -d "$JT_HOME"; then
80+
AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist])
81+
fi
82+
83+
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
84+
AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home])
85+
fi
86+
87+
JTREGEXE="$JT_HOME/bin/jtreg"
88+
if test ! -x "$JTREGEXE"; then
89+
AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not contain valid jtreg executable])
90+
fi
91+
92+
AC_MSG_CHECKING([for jtreg test harness])
93+
AC_MSG_RESULT([$JT_HOME])
94+
else
95+
# Try to locate jtreg
96+
if test "x$JT_HOME" != x; then
97+
# JT_HOME set in environment, use it
98+
if test ! -d "$JT_HOME"; then
99+
AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME])
100+
JT_HOME=
101+
else
102+
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
103+
AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME])
104+
JT_HOME=
105+
elif test ! -x "$JT_HOME/bin/jtreg"; then
106+
AC_MSG_WARN([Ignoring JT_HOME which does not contain valid jtreg executable: $JT_HOME])
107+
JT_HOME=
108+
else
109+
JTREGEXE="$JT_HOME/bin/jtreg"
110+
AC_MSG_NOTICE([Located jtreg using JT_HOME from environment])
111+
fi
112+
fi
113+
fi
114+
115+
if test "x$JT_HOME" = x; then
116+
# JT_HOME is not set in environment, or was deemed invalid.
117+
# Try to find jtreg on path
118+
UTIL_LOOKUP_PROGS(JTREGEXE, jtreg)
119+
if test "x$JTREGEXE" != x; then
120+
# That's good, now try to derive JT_HOME
121+
JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)`
122+
if test ! -e "$JT_HOME/lib/jtreg.jar"; then
123+
AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found])
124+
JT_HOME=
125+
JTREGEXE=
126+
else
127+
AC_MSG_NOTICE([Located jtreg using jtreg executable in path])
128+
fi
129+
fi
130+
fi
131+
132+
AC_MSG_CHECKING([for jtreg test harness])
133+
if test "x$JT_HOME" != x; then
134+
AC_MSG_RESULT([$JT_HOME])
135+
else
136+
AC_MSG_RESULT([no, not found])
137+
138+
if test "x$with_jtreg" = xyes; then
139+
AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.])
140+
fi
141+
fi
142+
fi
143+
144+
UTIL_FIXUP_EXECUTABLE(JTREGEXE)
145+
UTIL_FIXUP_PATH(JT_HOME)
146+
AC_SUBST(JT_HOME)
147+
148+
# Verify jtreg version
149+
if test "x$JT_HOME" != x; then
150+
AC_MSG_CHECKING([jtreg version number])
151+
# jtreg -version looks like this: "jtreg 6.1+1-19"
152+
# Extract actual version part ("6.1" in this case)
153+
jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2`
154+
jtreg_version=${jtreg_version_full/%+*}
155+
AC_MSG_RESULT([$jtreg_version])
156+
157+
# This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION
158+
comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"`
159+
comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"`
160+
if test $comparable_actual_version -lt $comparable_minimum_version ; then
161+
AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required])
162+
fi
163+
fi
164+
165+
AC_SUBST(JTREGEXE)
166+
])
167+
168+
# Setup the JIB dependency resolver
169+
AC_DEFUN_ONCE([LIB_TESTS_SETUP_JIB],
170+
[
171+
AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib],
172+
[Jib dependency management tool @<:@not used@:>@])])
173+
174+
if test "x$with_jib" = xno || test "x$with_jib" = x; then
175+
# jib disabled
176+
AC_MSG_CHECKING([for jib])
177+
AC_MSG_RESULT(no)
178+
elif test "x$with_jib" = xyes; then
179+
AC_MSG_ERROR([Must supply a value to --with-jib])
180+
else
181+
JIB_HOME="${with_jib}"
182+
AC_MSG_CHECKING([for jib])
183+
AC_MSG_RESULT(${JIB_HOME})
184+
if test ! -d "${JIB_HOME}"; then
185+
AC_MSG_ERROR([--with-jib must be a directory])
186+
fi
187+
JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar)
188+
if test ! -f "${JIB_JAR}"; then
189+
AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}])
190+
fi
191+
fi
192+
193+
AC_SUBST(JIB_HOME)
194+
])
195+
196+
################################################################################
197+
#
198+
# Check if building of the jtreg failure handler should be enabled.
199+
#
200+
AC_DEFUN_ONCE([LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER],
201+
[
202+
AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
203+
[forces build of the jtreg failure handler to be enabled, missing dependencies
204+
become fatal errors. Default is auto, where the failure handler is built if all
205+
dependencies are present and otherwise just disabled.])])
206+
207+
AC_MSG_CHECKING([if jtreg failure handler should be built])
208+
209+
if test "x$enable_jtreg_failure_handler" = "xyes"; then
210+
if test "x$JT_HOME" = "x"; then
211+
AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
212+
else
213+
BUILD_FAILURE_HANDLER=true
214+
AC_MSG_RESULT([yes, forced])
215+
fi
216+
elif test "x$enable_jtreg_failure_handler" = "xno"; then
217+
BUILD_FAILURE_HANDLER=false
218+
AC_MSG_RESULT([no, forced])
219+
elif test "x$enable_jtreg_failure_handler" = "xauto" \
220+
|| test "x$enable_jtreg_failure_handler" = "x"; then
221+
if test "x$JT_HOME" = "x"; then
222+
BUILD_FAILURE_HANDLER=false
223+
AC_MSG_RESULT([no, missing jtreg])
224+
else
225+
BUILD_FAILURE_HANDLER=true
226+
AC_MSG_RESULT([yes, jtreg present])
227+
fi
228+
else
229+
AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
230+
fi
231+
232+
AC_SUBST(BUILD_FAILURE_HANDLER)
233+
])

0 commit comments

Comments
 (0)