8180281: --with-jtreg is broken for many use cases
authorihse
Fri, 12 May 2017 19:11:14 +0200
changeset 45104 b8a6cd8674d1
parent 45103 85999d3d05f0
child 45105 bf3dae998ca2
8180281: --with-jtreg is broken for many use cases Reviewed-by: erikj
common/autoconf/generated-configure.sh
common/autoconf/toolchain.m4
make/RunTests.gmk
--- a/common/autoconf/generated-configure.sh	Fri May 12 19:09:50 2017 +0200
+++ b/common/autoconf/generated-configure.sh	Fri May 12 19:11:14 2017 +0200
@@ -5183,7 +5183,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1494608938
+DATE_WHEN_GENERATED=1494609053
 
 ###############################################################################
 #
@@ -48611,173 +48611,63 @@
 # Check whether --with-jtreg was given.
 if test "${with_jtreg+set}" = set; then :
   withval=$with_jtreg;
-else
-  with_jtreg=no
 fi
 
 
   if test "x$with_jtreg" = xno; then
     # jtreg disabled
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jtreg" >&5
-$as_echo_n "checking for jtreg... " >&6; }
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-  else
-    if test "x$with_jtreg" != xyes; then
-      # with path specified.
-      JT_HOME="$with_jtreg"
-    fi
-
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jtreg test harness" >&5
+$as_echo_n "checking for jtreg test harness... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, disabled" >&5
+$as_echo "no, disabled" >&6; }
+  elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then
+    # An explicit path is specified, use it.
+    JT_HOME="$with_jtreg"
+    if test ! -d "$JT_HOME"; then
+      as_fn_error $? "jtreg home directory from --with-jtreg=$with_jtreg does not exist" "$LINENO" 5
+    fi
+
+    if test ! -e "$JT_HOME/lib/jtreg.jar"; then
+      as_fn_error $? "jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home" "$LINENO" 5
+    fi
+
+    JTREGEXE="$JT_HOME/bin/jtreg"
+    if test ! -x "$JTREGEXE"; then
+      as_fn_error $? "jtreg home directory from --with-jtreg=$with_jtreg does not contain valid jtreg executable" "$LINENO" 5
+    fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jtreg test harness" >&5
+$as_echo_n "checking for jtreg test harness... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JT_HOME" >&5
+$as_echo "$JT_HOME" >&6; }
+  else
+    # Try to locate jtreg
     if test "x$JT_HOME" != x; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jtreg" >&5
-$as_echo_n "checking for jtreg... " >&6; }
-
-      # use JT_HOME enviroment var.
-
-  # Only process if variable expands to non-empty
-
-  if test "x$JT_HOME" != x; then
-    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
-
-  # Input might be given as Windows format, start by converting to
-  # unix format.
-  path="$JT_HOME"
-  new_path=`$CYGPATH -u "$path"`
-
-  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
-  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
-  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
-  # "foo.exe" is OK but "foo" is an error.
-  #
-  # This test is therefore slightly more accurate than "test -f" to check for file precense.
-  # It is also a way to make sure we got the proper file name for the real test later on.
-  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
-  if test "x$test_shortpath" = x; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JT_HOME, which resolves as \"$path\", is invalid." >&5
-$as_echo "$as_me: The path of JT_HOME, which resolves as \"$path\", is invalid." >&6;}
-    as_fn_error $? "Cannot locate the the path of JT_HOME" "$LINENO" 5
-  fi
-
-  # Call helper function which possibly converts this using DOS-style short mode.
-  # If so, the updated path is stored in $new_path.
-
-  input_path="$new_path"
-  # Check if we need to convert this using DOS-style short mode. If the path
-  # contains just simple characters, use it. Otherwise (spaces, weird characters),
-  # take no chances and rewrite it.
-  # Note: m4 eats our [], so we need to use [ and ] instead.
-  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
-  if test "x$has_forbidden_chars" != x; then
-    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
-    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
-    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
-    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
-      # Going to short mode and back again did indeed matter. Since short mode is
-      # case insensitive, let's make it lowercase to improve readability.
-      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-      # Now convert it back to Unix-style (cygpath)
-      input_path=`$CYGPATH -u "$shortmode_path"`
-      new_path="$input_path"
-    fi
-  fi
-
-  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
-  if test "x$test_cygdrive_prefix" = x; then
-    # As a simple fix, exclude /usr/bin since it's not a real path.
-    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
-      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
-      # a path prefixed by /cygdrive for fixpath to work.
-      new_path="$CYGWIN_ROOT_PATH$input_path"
-    fi
-  fi
-
-
-  if test "x$path" != "x$new_path"; then
-    JT_HOME="$new_path"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JT_HOME to \"$new_path\"" >&5
-$as_echo "$as_me: Rewriting JT_HOME to \"$new_path\"" >&6;}
-  fi
-
-    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
-
-  path="$JT_HOME"
-  has_colon=`$ECHO $path | $GREP ^.:`
-  new_path="$path"
-  if test "x$has_colon" = x; then
-    # Not in mixed or Windows style, start by that.
-    new_path=`cmd //c echo $path`
-  fi
-
-
-  input_path="$new_path"
-  # Check if we need to convert this using DOS-style short mode. If the path
-  # contains just simple characters, use it. Otherwise (spaces, weird characters),
-  # take no chances and rewrite it.
-  # Note: m4 eats our [], so we need to use [ and ] instead.
-  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
-  if test "x$has_forbidden_chars" != x; then
-    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
-    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-  fi
-
-
-  windows_path="$new_path"
-  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
-    unix_path=`$CYGPATH -u "$windows_path"`
-    new_path="$unix_path"
-  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
-    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
-    new_path="$unix_path"
-  fi
-
-  if test "x$path" != "x$new_path"; then
-    JT_HOME="$new_path"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting JT_HOME to \"$new_path\"" >&5
-$as_echo "$as_me: Rewriting JT_HOME to \"$new_path\"" >&6;}
-  fi
-
-  # Save the first 10 bytes of this path to the storage, so fixpath can work.
-  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
-
-    else
-      # We're on a unix platform. Hooray! :)
-      path="$JT_HOME"
-      has_space=`$ECHO "$path" | $GREP " "`
-      if test "x$has_space" != x; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of JT_HOME, which resolves as \"$path\", is invalid." >&5
-$as_echo "$as_me: The path of JT_HOME, which resolves as \"$path\", is invalid." >&6;}
-        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
-      fi
-
-      # Use eval to expand a potential ~
-      eval path="$path"
-      if test ! -f "$path" && test ! -d "$path"; then
-        as_fn_error $? "The path of JT_HOME, which resolves as \"$path\", is not found." "$LINENO" 5
-      fi
-
-      if test -d "$path"; then
-        JT_HOME="`cd "$path"; $THEPWDCMD -L`"
-      else
-        dir="`$DIRNAME "$path"`"
-        base="`$BASENAME "$path"`"
-        JT_HOME="`cd "$dir"; $THEPWDCMD -L`/$base"
-      fi
-    fi
-  fi
-
-
-      # jtreg win32 script works for everybody
-      JTREGEXE="$JT_HOME/bin/jtreg"
-
-      if test ! -f "$JTREGEXE"; then
-        as_fn_error $? "JTReg executable does not exist: $JTREGEXE" "$LINENO" 5
-      fi
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JTREGEXE" >&5
-$as_echo "$JTREGEXE" >&6; }
-    else
-      # try to find jtreg on path
-
+      # JT_HOME set in environment, use it
+      if test ! -d "$JT_HOME"; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring JT_HOME pointing to invalid directory: $JT_HOME" >&5
+$as_echo "$as_me: WARNING: Ignoring JT_HOME pointing to invalid directory: $JT_HOME" >&2;}
+        JT_HOME=
+      else
+        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME" >&5
+$as_echo "$as_me: WARNING: Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME" >&2;}
+          JT_HOME=
+        elif test ! -x "$JT_HOME/bin/jtreg"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring JT_HOME which does not contain valid jtreg executable: $JT_HOME" >&5
+$as_echo "$as_me: WARNING: Ignoring JT_HOME which does not contain valid jtreg executable: $JT_HOME" >&2;}
+          JT_HOME=
+        else
+          JTREGEXE="$JT_HOME/bin/jtreg"
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Located jtreg using JT_HOME from environment" >&5
+$as_echo "$as_me: Located jtreg using JT_HOME from environment" >&6;}
+        fi
+      fi
+    fi
+
+    if test "x$JT_HOME" = x; then
+      # JT_HOME is not set in environment, or was deemed invalid.
+      # Try to find jtreg on path
 
 
   # Publish this variable in the help.
@@ -48975,13 +48865,33 @@
   fi
 
 
-
-  if test "x$JTREGEXE" = x; then
-    as_fn_error $? "Could not find required tool for JTREGEXE" "$LINENO" 5
-  fi
-
-
-      JT_HOME="`$DIRNAME $JTREGEXE`"
+      if test "x$JTREGEXE" != x; then
+        # That's good, now try to derive JT_HOME
+        JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)`
+        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
+          { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring jtreg from path since a valid jtreg home cannot be found" >&5
+$as_echo "$as_me: WARNING: Ignoring jtreg from path since a valid jtreg home cannot be found" >&2;}
+          JT_HOME=
+          JTREGEXE=
+        else
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Located jtreg using jtreg executable in path" >&5
+$as_echo "$as_me: Located jtreg using jtreg executable in path" >&6;}
+        fi
+      fi
+    fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jtreg test harness" >&5
+$as_echo_n "checking for jtreg test harness... " >&6; }
+    if test "x$JT_HOME" != x; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JT_HOME" >&5
+$as_echo "$JT_HOME" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, not found" >&5
+$as_echo "no, not found" >&6; }
+
+      if test "x$with_jtreg" = xyes; then
+        as_fn_error $? "--with-jtreg was specified, but no jtreg found." "$LINENO" 5
+      fi
     fi
   fi
 
--- a/common/autoconf/toolchain.m4	Fri May 12 19:09:50 2017 +0200
+++ b/common/autoconf/toolchain.m4	Fri May 12 19:11:14 2017 +0200
@@ -926,38 +926,77 @@
 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
 [
   AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
-      [Regression Test Harness @<:@probed@:>@])],
-      [],
-      [with_jtreg=no])
+      [Regression Test Harness @<:@probed@:>@])])
 
   if test "x$with_jtreg" = xno; then
     # jtreg disabled
-    AC_MSG_CHECKING([for jtreg])
-    AC_MSG_RESULT(no)
-  else
-    if test "x$with_jtreg" != xyes; then
-      # with path specified.
-      JT_HOME="$with_jtreg"
+    AC_MSG_CHECKING([for jtreg test harness])
+    AC_MSG_RESULT([no, disabled])
+  elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then
+    # An explicit path is specified, use it.
+    JT_HOME="$with_jtreg"
+    if test ! -d "$JT_HOME"; then
+      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist])
+    fi
+
+    if test ! -e "$JT_HOME/lib/jtreg.jar"; then
+      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home])
+    fi
+
+    JTREGEXE="$JT_HOME/bin/jtreg"
+    if test ! -x "$JTREGEXE"; then
+      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not contain valid jtreg executable])
     fi
 
+    AC_MSG_CHECKING([for jtreg test harness])
+    AC_MSG_RESULT([$JT_HOME])
+  else
+    # Try to locate jtreg
     if test "x$JT_HOME" != x; then
-      AC_MSG_CHECKING([for jtreg])
-
-      # use JT_HOME enviroment var.
-      BASIC_FIXUP_PATH([JT_HOME])
-
-      # jtreg win32 script works for everybody
-      JTREGEXE="$JT_HOME/bin/jtreg"
+      # JT_HOME set in environment, use it
+      if test ! -d "$JT_HOME"; then
+        AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME])
+        JT_HOME=
+      else
+        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
+          AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME])
+          JT_HOME=
+        elif test ! -x "$JT_HOME/bin/jtreg"; then
+          AC_MSG_WARN([Ignoring JT_HOME which does not contain valid jtreg executable: $JT_HOME])
+          JT_HOME=
+        else
+          JTREGEXE="$JT_HOME/bin/jtreg"
+          AC_MSG_NOTICE([Located jtreg using JT_HOME from environment])
+        fi
+      fi
+    fi
 
-      if test ! -f "$JTREGEXE"; then
-        AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
+    if test "x$JT_HOME" = x; then
+      # JT_HOME is not set in environment, or was deemed invalid.
+      # Try to find jtreg on path
+      BASIC_PATH_PROGS(JTREGEXE, jtreg)
+      if test "x$JTREGEXE" != x; then
+        # That's good, now try to derive JT_HOME
+        JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)`
+        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
+          AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found])
+          JT_HOME=
+          JTREGEXE=
+        else
+          AC_MSG_NOTICE([Located jtreg using jtreg executable in path])
+        fi
       fi
+    fi
 
-      AC_MSG_RESULT($JTREGEXE)
+    AC_MSG_CHECKING([for jtreg test harness])
+    if test "x$JT_HOME" != x; then
+      AC_MSG_RESULT([$JT_HOME])
     else
-      # try to find jtreg on path
-      BASIC_REQUIRE_PROGS(JTREGEXE, jtreg)
-      JT_HOME="`$DIRNAME $JTREGEXE`"
+      AC_MSG_RESULT([no, not found])
+
+      if test "x$with_jtreg" = xyes; then
+        AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.])
+      fi
     fi
   fi
 
--- a/make/RunTests.gmk	Fri May 12 19:09:50 2017 +0200
+++ b/make/RunTests.gmk	Fri May 12 19:11:14 2017 +0200
@@ -299,6 +299,12 @@
   $1_TEST_NAME := $$(strip $$(patsubst jtreg:%, %, $$($1_TEST)))
   $1_COMPONENT := $$(firstword $$(subst /, $$(SPACE), $$($1_TEST_NAME)))
 
+  ifeq ($$(JT_HOME), )
+    $$(info Error: jtreg framework is not found.)
+    $$(info Please run configure using --with-jtreg.)
+    $$(error Cannot continue)
+  endif
+
   # Unfortunately, we need different defaults for some JTREG values,
   # depending on what component we're running.