1 #
   2 # Copyright (c) 2018, 2020, 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 #
  28 # Check for graalunit libs, needed for running graalunit tests.
  29 #
  30 AC_DEFUN_ONCE([LIB_TESTS_SETUP_GRAALUNIT],
  31 [
  32   AC_ARG_WITH(graalunit-lib, [AS_HELP_STRING([--with-graalunit-lib],
  33       [specify location of 3rd party libraries used by Graal unit tests])])
  34 
  35   GRAALUNIT_LIB=
  36   if test "x${with_graalunit_lib}" != x; then
  37     AC_MSG_CHECKING([for graalunit libs])
  38     if test "x${with_graalunit_lib}" = xno; then
  39       AC_MSG_RESULT([disabled, graalunit tests can not be run])
  40     elif test "x${with_graalunit_lib}" = xyes; then
  41       AC_MSG_RESULT([not specified])
  42       AC_MSG_ERROR([You must specify the path to 3rd party libraries used by Graal unit tests])
  43     else
  44       GRAALUNIT_LIB="${with_graalunit_lib}"
  45       if test ! -d "${GRAALUNIT_LIB}"; then
  46         AC_MSG_RESULT([no])
  47         AC_MSG_ERROR([Could not find graalunit 3rd party libraries as specified. (${with_graalunit_lib})])
  48       else
  49         AC_MSG_RESULT([$GRAALUNIT_LIB])
  50       fi
  51     fi
  52   fi
  53 
  54   UTIL_FIXUP_PATH([GRAALUNIT_LIB])
  55   AC_SUBST(GRAALUNIT_LIB)
  56 ])
  57 
  58 ###############################################################################
  59 #
  60 # Setup and check for gtest framework source files
  61 #
  62 AC_DEFUN_ONCE([LIB_TESTS_SETUP_GTEST],
  63 [
  64   AC_ARG_WITH(gtest, [AS_HELP_STRING([--with-gtest],
  65       [specify prefix directory for the gtest framework])])
  66 
  67   if test "x${with_gtest}" != x; then
  68     AC_MSG_CHECKING([for gtest])
  69     if test "x${with_gtest}" = xno; then
  70       AC_MSG_RESULT([no, disabled])
  71     elif test "x${with_gtest}" = xyes; then
  72       AC_MSG_RESULT([no, error])
  73       AC_MSG_ERROR([--with-gtest must have a value])
  74     else
  75       if ! test -s "${with_gtest}/googletest/include/gtest/gtest.h"; then
  76         AC_MSG_RESULT([no])
  77         AC_MSG_ERROR([Can't find 'googletest/include/gtest/gtest.h' under ${with_gtest} given with the --with-gtest option.])
  78       elif ! test -s "${with_gtest}/googlemock/include/gmock/gmock.h"; then
  79         AC_MSG_RESULT([no])
  80         AC_MSG_ERROR([Can't find 'googlemock/include/gmock/gmock.h' under ${with_gtest} given with the --with-gtest option.])
  81       else
  82         GTEST_FRAMEWORK_SRC=${with_gtest}
  83         AC_MSG_RESULT([$GTEST_FRAMEWORK_SRC])
  84       fi
  85     fi
  86   fi
  87 
  88   AC_SUBST(GTEST_FRAMEWORK_SRC)
  89 ])
  90 
  91 ###############################################################################
  92 #
  93 # Setup and check the Java Microbenchmark Harness
  94 #
  95 AC_DEFUN_ONCE([LIB_TESTS_SETUP_JMH],
  96 [
  97   AC_ARG_WITH(jmh, [AS_HELP_STRING([--with-jmh],
  98       [Java Microbenchmark Harness for building the OpenJDK Microbenchmark Suite])])
  99 
 100   AC_MSG_CHECKING([for jmh (Java Microbenchmark Harness)])
 101   if test "x$with_jmh" = xno || test "x$with_jmh" = x; then
 102     AC_MSG_RESULT([no, disabled])
 103   elif test "x$with_jmh" = xyes; then
 104     AC_MSG_RESULT([no, error])
 105     AC_MSG_ERROR([--with-jmh requires a directory containing all jars needed by JMH])
 106   else
 107     # Path specified
 108     JMH_HOME="$with_jmh"
 109     if test ! -d [$JMH_HOME]; then
 110       AC_MSG_RESULT([no, error])
 111       AC_MSG_ERROR([$JMH_HOME does not exist or is not a directory])
 112     fi
 113     AC_MSG_RESULT([yes, $JMH_HOME])
 114 
 115     UTIL_FIXUP_PATH([JMH_HOME])
 116 
 117     jar_names="jmh-core jmh-generator-annprocess jopt-simple commons-math3"
 118     for jar in $jar_names; do
 119       found_jar_files=$($ECHO $(ls $JMH_HOME/$jar-*.jar 2> /dev/null))
 120 
 121       if test "x$found_jar_files" = x; then
 122         AC_MSG_ERROR([--with-jmh does not contain $jar-*.jar])
 123       elif ! test -e "$found_jar_files"; then
 124         AC_MSG_ERROR([--with-jmh contain multiple $jar-*.jar: $found_jar_files])
 125       fi
 126 
 127       found_jar_var_name=found_${jar//-/_}
 128       eval $found_jar_var_name='"'$found_jar_files'"'
 129     done
 130 
 131     JMH_CORE_JAR=$found_jmh_core
 132     JMH_GENERATOR_JAR=$found_jmh_generator_annprocess
 133     JMH_JOPT_SIMPLE_JAR=$found_jopt_simple
 134     JMH_COMMONS_MATH_JAR=$found_commons_math3
 135 
 136 
 137     if [ [[ "$JMH_CORE_JAR" =~ jmh-core-(.*)\.jar$ ]] ] ; then
 138       JMH_VERSION=${BASH_REMATCH[[1]]}
 139     else
 140       JMH_VERSION=unknown
 141     fi
 142 
 143     AC_MSG_NOTICE([JMH core version: $JMH_VERSION])
 144   fi
 145 
 146   AC_SUBST(JMH_CORE_JAR)
 147   AC_SUBST(JMH_GENERATOR_JAR)
 148   AC_SUBST(JMH_JOPT_SIMPLE_JAR)
 149   AC_SUBST(JMH_COMMONS_MATH_JAR)
 150   AC_SUBST(JMH_VERSION)
 151 ])