From: David MacKenzie Date: Tue, 19 Jul 1994 19:01:36 +0000 (+0000) Subject: entered into RCS X-Git-Tag: fsf-origin~577 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3f2f2dba1864f8a5b5a554d31c239786ed05463;p=thirdparty%2Fautoconf.git entered into RCS --- diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp new file mode 100644 index 000000000..e91e6e277 --- /dev/null +++ b/testsuite/config/unix.exp @@ -0,0 +1,113 @@ +# -*- TCL -*- +# Copyright (C) 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +# Modified by David MacKenzie (djm@cygnus.com) from the gcc files +# written by Rob Savoye (rob@cygnus.com). + +# +# Called by runtest. +# Extract and print the version number of autoconf. +# +proc autoconf_version {} { + global AUTOCONF + global AUTOCONFFLAGS + + if {[which $AUTOCONF] != 0} then { + set tmp [ eval exec $AUTOCONF $AUTOCONFFLAGS --version /dev/null ] + regexp "version.*$" $tmp version + if [info exists version] then { + clone_output "[which $AUTOCONF] $version\n" + } else { + warning "cannot get version from $tmp." + } + } else { + warning "$AUTOCONF, program does not exist" + } +} + +# +# Compile a configure.in using autoconf. +# Runs autoconf and leaves the output in $comp_output. +# Called by individual test scripts. +# Return 1 if ok, 0 if not. +proc autoconf_start { configin } { + global verbose + global AUTOCONF + global AUTOCONFFLAGS + global comp_output + + if {[which $AUTOCONF] == 0} then { + error "$AUTOCONF, program does not exist" + exit 1 + } + + # Replace ".in" with ".conf". +# set configout "[file rootname $configin].conf" + set configout "[file rootname $configin]" + + send_log "$AUTOCONF $AUTOCONFFLAGS $configin > $configout\n" + if $verbose>1 then { + send_user "Spawning \"$AUTOCONF $AUTOCONFFLAGS $configin > $configout\"\n" + } + + catch "exec $AUTOCONF $AUTOCONFFLAGS $configin > $configout" comp_output + if ![string match "" $comp_output] then { + send_log "$comp_output\n" + if $verbose>1 then { + send_user "$comp_output\n" + } + } + catch "exec chmod +x $configout" + return 1 +} + +# +# Execute the configure script. +# Leaves the output in $exec_output. +# Called by individual test scripts. +# Return 1 if successful so far, 0 if failure already. +proc autoconf_load { args } { + global verbose + global exec_output + + if ![file exists $args] then { + error "$args, configure script does not exist" + return 0 + } + + # Capture only stderr in exec_output, not "creating Makefile" etc. + catch "exec $args >/dev/null" exec_output + if $verbose>1 then { + send_user "Executed $args\n" + } + if ![string match "" $exec_output] then { + fail "$args, problem while executing configure script" + send_log "$exec_output\n" + return 0 + } else { + return 1 + } +} + +# +# Called by runtest. +# Clean up (remove temporary files) before runtest exits. +# +proc autoconf_exit {} { +} + +load_lib common.exp diff --git a/testsuite/lib/common.exp b/testsuite/lib/common.exp new file mode 100644 index 000000000..df34fddb5 --- /dev/null +++ b/testsuite/lib/common.exp @@ -0,0 +1,86 @@ +# -*- TCL -*- +# Auxiliary procedures for autoconf tests. + +# Create a configure.in from a string. +# Return 1 if successful, 0 if an error occurs. +proc autoconf_create {configin contents} { + if [catch {set hand [open $configin "w"]}] { + error "$configin, cannot create" + return 0 + } + puts $hand "AC_INIT(Makefile.in) +$contents +AC_OUTPUT(Makefile)" + close $hand + return 1 +} + +# Compile a configure.in into a configure +# and call error if there's any output (undefined macros, can't +# find library files, etc.). +proc autoconf_start_plus {configin} { + global comp_output + + set status [autoconf_start $configin] + if {$status==0} { + return 0 + } + # Examine $comp_output. + if ![string match "" "$comp_output"] then { + fail "$configin, running autoconf failed" + return 0 + } + return 1 +} + +# Execute a configure script and check the output +# against what it's supposed to be. +# Return 1 if successful so far, 0 if failure already. +proc autoconf_load_plus {args} { + global exec_output + + set status [autoconf_load $args] + if {$status==0} { + return 0 + } + if [string match "*:*" "$exec_output"] then { + fail "$args, did not execute correctly" + return 0 + } + return 1 +} + +# Remove generated configuration files for test CONFIG. +# Return 1 if successful, 0 if not. +proc autoconf_remove {config} { + if [catch "exec rm -f $config $config.in conftest* config.status config.cache config.log"] { + warning "$config output files, cannot remove" + return 0 + } + return 1 +} + +# The standard autoconf test: compile, run, and remove +# a simple configure script. +proc autoconf_test {testname contents} { + if ![autoconf_remove $testname] { + return 0 + } + if ![autoconf_create $testname.in "$contents"] { + return 0 + } + if ![autoconf_start_plus $testname.in] { + autoconf_remove $testname + return 0 + } + if ![autoconf_load_plus $testname] { + autoconf_remove $testname + return 0 + } + if ![autoconf_remove $testname] { + return 0 + } + + pass "$testname" + return 1 +}