8239860: Add support for testing the configure script
Reviewed-by: erikj
This commit is contained in:
parent
ca838e68c9
commit
d7a0206262
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -1049,7 +1049,7 @@ define SetupRunSpecialTestBody
|
||||
else ifeq ($$($1_TEST_NAME), make)
|
||||
$1_TEST_COMMAND_LINE := \
|
||||
($(CD) $(TOPDIR)/test/make && $(MAKE) $(MAKE_ARGS) -f \
|
||||
TestMake.gmk $$($1_TEST_ARGS))
|
||||
TestMake.gmk $$($1_TEST_ARGS) TEST_SUPPORT_DIR="$$($1_TEST_SUPPORT_DIR)")
|
||||
else
|
||||
$$(error Invalid special test specification: $$($1_TEST_NAME))
|
||||
endif
|
||||
|
@ -95,6 +95,27 @@ AC_DEFUN([UTIL_DEFUN_NAMED],
|
||||
])
|
||||
])
|
||||
|
||||
###############################################################################
|
||||
# Assert that a programmatic condition holds. If not, exit with an error message.
|
||||
# Check that two strings are equal.
|
||||
#
|
||||
# $1: The actual string found
|
||||
# $2: The expected string
|
||||
# $3: An message to print in case of failure [optional]
|
||||
#
|
||||
AC_DEFUN([UTIL_ASSERT_STRING_EQUALS],
|
||||
[
|
||||
ASSERTION_MSG="m4_normalize([$3])"
|
||||
if test "x[$1]" != "x[$2]"; then
|
||||
$ECHO Assertion failed: Actual value '[$1]' \("[$1]"\) did not match \
|
||||
expected value '[$2]' \("[$2]"\)
|
||||
if test "x$ASSERTION_MSG" != x; then
|
||||
$ECHO Assertion message: "$ASSERTION_MSG"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
])
|
||||
|
||||
###############################################################################
|
||||
# Check if a list of space-separated words are selected only from a list of
|
||||
# space-separated legal words. Typical use is to see if a user-specified
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,7 +42,11 @@ idea:
|
||||
compile-commands:
|
||||
+$(MAKE) -f TestCompileCommands.gmk $(TEST_SUBTARGET)
|
||||
|
||||
TARGETS += make-base java-compilation copy-files idea compile-commands
|
||||
configure:
|
||||
$(BASH) $(TOPDIR)/test/make/autoconf/test-configure.sh \
|
||||
"$(AUTOCONF)" "$(TOPDIR)" "$(TEST_SUPPORT_DIR)"
|
||||
|
||||
TARGETS += make-base java-compilation copy-files idea compile-commands configure
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
|
78
test/make/autoconf/test-configure.sh
Normal file
78
test/make/autoconf/test-configure.sh
Normal file
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Arguments passed to us from makefile.
|
||||
AUTOCONF="$1"
|
||||
TOPDIR="$2"
|
||||
TEST_SUPPORT_DIR="$3"
|
||||
|
||||
mkdir -p $TEST_SUPPORT_DIR/test-conf
|
||||
cd $TEST_SUPPORT_DIR/test-conf
|
||||
|
||||
conf_script_dir="$TOPDIR/make/autoconf"
|
||||
generated_script="$TEST_SUPPORT_DIR/generated-test-configure.sh"
|
||||
|
||||
# Generate configure script with test hooks compiled in.
|
||||
echo "Generating test-configure script at $generated_script"
|
||||
cat $conf_script_dir/configure.ac |
|
||||
sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([test.m4])|" | \
|
||||
${AUTOCONF} -W all -I$TOPDIR/test/make/autoconf -I$conf_script_dir - \
|
||||
> $generated_script
|
||||
rm -rf autom4te.cache
|
||||
|
||||
# Sanity check
|
||||
if test ! -s $generated_script; then
|
||||
echo "Error: Failed to generate test-configure script" 1>&2
|
||||
rm -f $generated_script
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure all shell commands are executed with the C locale
|
||||
export LC_ALL=C
|
||||
|
||||
# Export our null command line
|
||||
CONFIGURE_COMMAND_LINE=""
|
||||
|
||||
# Force autoconf to use bash. This also means we must disable autoconf re-exec.
|
||||
export CONFIG_SHELL=$BASH
|
||||
export _as_can_reexec=no
|
||||
|
||||
# Now transfer control to the script generated by autoconf. This is where the
|
||||
# main work is done.
|
||||
|
||||
RCDIR=`mktemp -dt jdk-build-configure.tmp.XXXXXX` || exit $?
|
||||
trap "rm -rf \"$RCDIR\"" EXIT
|
||||
conf_logfile=./configure.log
|
||||
(exec 3>&1 ; ((. $generated_script --enable-option-checking=fatal 2>&1 1>&3 ) \
|
||||
; echo $? > "$RCDIR/rc" ) \
|
||||
| tee -a $conf_logfile 1>&2 ; exec 3>&-) | tee -a $conf_logfile
|
||||
|
||||
conf_result_code=`cat "$RCDIR/rc"`
|
||||
|
||||
if test $conf_result_code -ne 0; then
|
||||
echo "=============================="
|
||||
echo "Configure tests finished with failure. Result code: $conf_result_code"
|
||||
fi
|
||||
|
||||
exit $conf_result_code
|
61
test/make/autoconf/test.m4
Normal file
61
test/make/autoconf/test.m4
Normal file
@ -0,0 +1,61 @@
|
||||
#
|
||||
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Unit tests for the configure script
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
AC_DEFUN([TEST_STRING_OPS],
|
||||
[
|
||||
FEW="ninja banan pepparkaka"
|
||||
MANY="banan antarktis pepparkaka ninjamask bana"
|
||||
|
||||
EXPECTED_NON_MATCHING="antarktis ninjamask bana"
|
||||
UTIL_GET_NON_MATCHING_VALUES(ACTUAL, $MANY, $FEW)
|
||||
UTIL_ASSERT_STRING_EQUALS($ACTUAL, $EXPECTED_NON_MATCHING, \
|
||||
[UTIL_GET_NON_MATCHING_VALUES failed])
|
||||
|
||||
EXPECTED_MATCHING="banan pepparkaka"
|
||||
UTIL_GET_MATCHING_VALUES(ACTUAL, $FEW, $MANY)
|
||||
UTIL_ASSERT_STRING_EQUALS($ACTUAL, $EXPECTED_MATCHING, \
|
||||
[UTIL_GET_MATCHING_VALUES failed])
|
||||
])
|
||||
|
||||
# Use the CUSTOM_EARLY_HOOK to inject our test after basic init is done.
|
||||
AC_DEFUN_ONCE([CUSTOM_EARLY_HOOK],
|
||||
[
|
||||
$PRINTF "\nStarting configure tests\n"
|
||||
$PRINTF "==============================\n"
|
||||
|
||||
TEST_STRING_OPS
|
||||
|
||||
# If no assertions failed, report success
|
||||
$PRINTF "==============================\n"
|
||||
$PRINTF "Configure tests finished successfully\n\n"
|
||||
exit 0
|
||||
])
|
Loading…
x
Reference in New Issue
Block a user