1 # 2 # Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 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. 10 # 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). 16 # 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. 20 # 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 23 # questions. 24 # 25 26 ################################################################################ 27 # Setup libraries and functionalities needed to test the JDK. 28 ################################################################################ 29 30 # Minimum supported versions 31 JTREG_MINIMUM_VERSION=7.1.1 32 GTEST_MINIMUM_VERSION=1.13.0 33 34 ############################################################################### 35 # 36 # Setup and check for gtest framework source files 37 # 38 AC_DEFUN_ONCE([LIB_TESTS_SETUP_GTEST], 39 [ 40 AC_ARG_WITH(gtest, [AS_HELP_STRING([--with-gtest], 41 [specify prefix directory for the gtest framework])]) 42 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]) 50 else 51 if ! test -s "${with_gtest}/googletest/include/gtest/gtest.h"; then 52 AC_MSG_RESULT([no]) 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 55 AC_MSG_RESULT([no]) 56 AC_MSG_ERROR([Can't find 'googlemock/include/gmock/gmock.h' under ${with_gtest} given with the --with-gtest option.]) 57 else 58 GTEST_FRAMEWORK_SRC=$with_gtest 59 AC_MSG_RESULT([$GTEST_FRAMEWORK_SRC]) 60 UTIL_FIXUP_PATH([GTEST_FRAMEWORK_SRC]) 61 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 -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]) 69 fi 70 fi 71 fi 72 fi 73 74 AC_SUBST(GTEST_FRAMEWORK_SRC) 75 ]) 76 77 ############################################################################### 78 # 79 # Setup and check the Java Microbenchmark Harness 80 # 81 AC_DEFUN_ONCE([LIB_TESTS_SETUP_JMH], 82 [ 83 AC_ARG_WITH(jmh, [AS_HELP_STRING([--with-jmh], 84 [Java Microbenchmark Harness for building the OpenJDK Microbenchmark Suite])]) 85 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]) 92 else 93 # Path specified 94 JMH_HOME="$with_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]) 98 fi 99 AC_MSG_RESULT([yes, $JMH_HOME]) 100 101 UTIL_FIXUP_PATH([JMH_HOME]) 102 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)) 106 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]) 111 fi 112 113 found_jar_var_name=found_${jar//-/_} 114 eval $found_jar_var_name='"'$found_jar_files'"' 115 done 116 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 121 122 123 if [ [[ "$JMH_CORE_JAR" =~ jmh-core-(.*)\.jar$ ]] ] ; then 124 JMH_VERSION=${BASH_REMATCH[[1]]} 125 else 126 JMH_VERSION=unknown 127 fi 128 129 AC_MSG_NOTICE([JMH core version: $JMH_VERSION]) 130 fi 131 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) 137 ]) 138 139 # Setup the JTReg Regression Test Harness. 140 AC_DEFUN_ONCE([LIB_TESTS_SETUP_JTREG], 141 [ 142 AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], 143 [Regression Test Harness @<:@probed@:>@])]) 144 145 if test "x$with_jtreg" = xno; then 146 # jtreg disabled 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" 153 else 154 case "$with_jtreg" in 155 *.zip ) 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 160 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)) 165 fi 166 ;; 167 * ) 168 ;; 169 esac 170 fi 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]) 174 fi 175 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]) 178 fi 179 180 AC_MSG_CHECKING([for jtreg test harness]) 181 AC_MSG_RESULT([$JT_HOME]) 182 else 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]) 188 JT_HOME= 189 else 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]) 192 JT_HOME= 193 else 194 AC_MSG_NOTICE([Located jtreg using JT_HOME from environment]) 195 fi 196 fi 197 fi 198 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]) 208 JT_HOME= 209 else 210 AC_MSG_NOTICE([Located jtreg using jtreg executable in path]) 211 fi 212 fi 213 fi 214 215 AC_MSG_CHECKING([for jtreg test harness]) 216 if test "x$JT_HOME" != x; then 217 AC_MSG_RESULT([$JT_HOME]) 218 else 219 AC_MSG_RESULT([no, not found]) 220 221 if test "x$with_jtreg" = xyes; then 222 AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.]) 223 fi 224 fi 225 fi 226 227 UTIL_FIXUP_PATH(JT_HOME) 228 AC_SUBST(JT_HOME) 229 230 # Verify jtreg version 231 if test "x$JT_HOME" != x; then 232 AC_MSG_CHECKING([jtreg version number]) 233 # jtreg -version looks like this: "jtreg 6.1+1-19" 234 # Extract actual version part ("6.1" in this case) 235 jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2` 236 jtreg_version=${jtreg_version_full/%+*} 237 AC_MSG_RESULT([$jtreg_version]) 238 239 # This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION 240 comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"` 241 comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"` 242 if test $comparable_actual_version -lt $comparable_minimum_version ; then 243 AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required]) 244 fi 245 fi 246 ]) 247 248 # Setup the JTReg Regression Test Harness. 249 AC_DEFUN_ONCE([LIB_TESTS_SETUP_JTREG_MW], 250 [ 251 AC_ARG_WITH(jtregMW, [AS_HELP_STRING([--with-jtregMW], 252 [Regression Test Harness @<:@probed@:>@])]) 253 254 if test "x$with_jtregMW" = xno; then 255 # jtreg disabled 256 AC_MSG_CHECKING([for jtreg test harness]) 257 AC_MSG_RESULT([no, disabled]) 258 elif test "x$with_jtregMW" != xyes && test "x$with_jtregMW" != x; then 259 # An explicit path is specified, use it. 260 JT_HOME_MW="$with_jtregMW" 261 UTIL_FIXUP_PATH([JT_HOME_MW]) 262 if test ! -d "$JT_HOME_MW"; then 263 AC_MSG_ERROR([jtreg home directory from --with-jtregMW=$with_jtregMW does not exist]) 264 fi 265 266 if test ! -e "$JT_HOME_MW/lib/jtreg.jar"; then 267 AC_MSG_ERROR([jtreg home directory from --with-jtregMW=$with_jtregMW is not a valid jtreg home]) 268 fi 269 270 JTREGEXE_MW="$JT_HOME_MW/bin/jtreg" 271 if test ! -x "$JTREGEXE_MW"; then 272 AC_MSG_ERROR([jtreg home directory from --with-jtregMW=$with_jtregMW does not contain valid jtreg executable]) 273 fi 274 275 AC_MSG_CHECKING([for jtreg test harness]) 276 AC_MSG_RESULT([$JT_HOME_MW]) 277 else 278 # Try to locate jtreg 279 if test "x$JT_HOME_MW" != x; then 280 # JT_HOME_MW set in environment, use it 281 if test ! -d "$JT_HOME_MW"; then 282 AC_MSG_WARN([Ignoring JT_HOME_MW pointing to invalid directory: $JT_HOME_MW]) 283 JT_HOME_MW= 284 else 285 if test ! -e "$JT_HOME_MW/lib/jtreg.jar"; then 286 AC_MSG_WARN([Ignoring JT_HOME_MW which is not a valid jtreg home: $JT_HOME_MW]) 287 JT_HOME_MW= 288 elif test ! -x "$JT_HOME_MW/bin/jtreg"; then 289 AC_MSG_WARN([Ignoring JT_HOME_MW which does not contain valid jtreg executable: $JT_HOME_MW]) 290 JT_HOME_MW= 291 else 292 JTREGEXE_MW="$JT_HOME_MW/bin/jtreg" 293 AC_MSG_NOTICE([Located jtreg using JT_HOME_MW from environment]) 294 fi 295 fi 296 fi 297 298 if test "x$JT_HOME_MW" = x; then 299 # JT_HOME_MW is not set in environment, or was deemed invalid. 300 # Try to find jtreg on path 301 UTIL_LOOKUP_PROGS(JTREGEXE_MW, jtreg) 302 if test "x$JTREGEXE_MW" != x; then 303 # That's good, now try to derive JT_HOME_MW 304 JT_HOME_MW=`(cd $($DIRNAME $JTREGEXE_MW)/.. && pwd)` 305 if test ! -e "$JT_HOME_MW/lib/jtreg.jar"; then 306 AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found]) 307 JT_HOME_MW= 308 JTREGEXE_MW= 309 else 310 AC_MSG_NOTICE([Located jtreg using jtreg executable in path]) 311 fi 312 fi 313 fi 314 315 AC_MSG_CHECKING([for jtreg test harness]) 316 if test "x$JT_HOME_MW" != x; then 317 AC_MSG_RESULT([$JT_HOME_MW]) 318 else 319 AC_MSG_RESULT([no, not found]) 320 321 if test "x$with_jtregMW" = xyes; then 322 AC_MSG_ERROR([--with-jtregMW was specified, but no jtreg found.]) 323 fi 324 fi 325 fi 326 327 UTIL_FIXUP_EXECUTABLE(JTREGEXE_MW) 328 UTIL_FIXUP_PATH(JT_HOME_MW) 329 AC_SUBST(JT_HOME_MW) 330 AC_SUBST(JTREGEXE_MW) 331 ]) 332 333 # Setup the JIB dependency resolver 334 AC_DEFUN_ONCE([LIB_TESTS_SETUP_JIB], 335 [ 336 AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib], 337 [Jib dependency management tool @<:@not used@:>@])]) 338 339 if test "x$with_jib" = xno || test "x$with_jib" = x; then 340 # jib disabled 341 AC_MSG_CHECKING([for jib]) 342 AC_MSG_RESULT(no) 343 elif test "x$with_jib" = xyes; then 344 AC_MSG_ERROR([Must supply a value to --with-jib]) 345 else 346 JIB_HOME="${with_jib}" 347 AC_MSG_CHECKING([for jib]) 348 AC_MSG_RESULT(${JIB_HOME}) 349 if test ! -d "${JIB_HOME}"; then 350 AC_MSG_ERROR([--with-jib must be a directory]) 351 fi 352 JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar) 353 if test ! -f "${JIB_JAR}"; then 354 AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}]) 355 fi 356 fi 357 358 AC_SUBST(JIB_HOME) 359 ]) 360 361 ################################################################################ 362 # 363 # Check if building of the jtreg failure handler should be enabled. 364 # 365 AC_DEFUN_ONCE([LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER], 366 [ 367 if test "x$BUILD_ENV" = "xci"; then 368 BUILD_FAILURE_HANDLER_DEFAULT=auto 369 else 370 BUILD_FAILURE_HANDLER_DEFAULT=false 371 fi 372 373 UTIL_ARG_ENABLE(NAME: jtreg-failure-handler, DEFAULT: $BUILD_FAILURE_HANDLER_DEFAULT, 374 RESULT: BUILD_FAILURE_HANDLER, 375 DESC: [enable building of the jtreg failure handler], 376 DEFAULT_DESC: [enabled if jtreg is present and build env is CI], 377 CHECKING_MSG: [if the jtreg failure handler should be built], 378 CHECK_AVAILABLE: [ 379 AC_MSG_CHECKING([if the jtreg failure handler is available]) 380 if test "x$JT_HOME" != "x"; then 381 AC_MSG_RESULT([yes]) 382 else 383 AVAILABLE=false 384 AC_MSG_RESULT([no (jtreg not present)]) 385 fi 386 ]) 387 AC_SUBST(BUILD_FAILURE_HANDLER) 388 ]) 389 390 AC_DEFUN_ONCE([LIB_TESTS_ENABLE_DISABLE_JTREG_MAIN_WRAPPER], 391 [ 392 UTIL_ARG_ENABLE(NAME: jtreg-main-wrapper, DEFAULT: auto, 393 RESULT: BUILD_JTREG_MAIN_WRAPPER, 394 DESC: [enable building of the jtreg main wrapper], 395 DEFAULT_DESC: [enabled if jtreg is present], 396 CHECKING_MSG: [if the jtreg main wrapper should be built], 397 CHECK_AVAILABLE: [ 398 AC_MSG_CHECKING([if the jtreg main wrapper is available]) 399 if test "x$JT_HOME_MW" != "x"; then 400 AC_MSG_RESULT([yes]) 401 else 402 AVAILABLE=false 403 AC_MSG_RESULT([no (jtreg not present)]) 404 fi 405 ]) 406 AC_SUBST(BUILD_JTREG_MAIN_WRAPPER) 407 ])