source: trunk/essentials/sys-devel/autoconf-2.13/testsuite/lib/common.exp

Last change on this file was 3157, checked in by bird, 18 years ago

autoconf 2.13

File size: 3.4 KB
Line 
1# -*- TCL -*-
2# Auxiliary procedures for autoconf tests.
3# Copyright (C) 1994 Free Software Foundation, Inc.
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19# Written by David MacKenzie <djm@gnu.ai.mit.edu>.
20
21
22#
23# Create a configure.in from a string.
24# CONFIG.in is the file to create containing CONTENTS plus boilerplate.
25# Return 1 if successful, 0 if an error occurs.
26proc autoconf_create {config contents} {
27 if [catch {open "$config.in" "w"} hand] {
28 error "$config, cannot create $config.in"
29 return 0
30 }
31 puts $hand "AC_INIT(confdummy.in)
32$contents
33AC_OUTPUT(confdummy)"
34 close $hand
35
36 if [catch {open "confdummy.in" "w"} hand] {
37 error "$config, cannot create confdummy.in"
38 return 0
39 }
40 puts $hand "# This is a dummy file for testing.
41srcdir = @srcdir@
42# Please ignore this file."
43 close $hand
44
45 return 1
46}
47
48# Compile a configure.in into a configure
49# and call error if there's any output (undefined macros, can't
50# find library files, etc.).
51proc autoconf_start_plus {configout} {
52 global comp_output
53
54 set status [autoconf_start $configout]
55 if {$status==0} {
56 return 0
57 }
58 # Examine $comp_output.
59 if [string match "*is obsolete*" "$comp_output"] then {
60 return 1
61 }
62 if [string match "*allow cross*" "$comp_output"] then {
63 return 1
64 }
65 if ![string match "" "$comp_output"] then {
66 fail "$configout, problem with running autoconf"
67 return 0
68 }
69 return 1
70}
71
72# Execute a configure script and check the output
73# against what it's supposed to be.
74# Return 1 if successful so far, 0 if failure already.
75proc autoconf_load_plus {args} {
76 global exec_output
77
78 set status [autoconf_load $args]
79 if {$status==0} {
80 return 0
81 }
82 if [string match "*:*" "$exec_output"] then {
83 fail "$args, problem with executing"
84 return 0
85 }
86 return 1
87}
88
89# Remove generated configuration files for test CONFIG.
90# Return 1 if successful, 0 if not.
91proc autoconf_remove {config} {
92 if [catch "exec rm -f $config $config.in [glob -nocomplain conftest* confdummy*] config.status config.cache config.log"] {
93 warning "$config output files, cannot remove"
94 return 0
95 }
96 return 1
97}
98
99# The standard autoconf test: create, compile, run, and remove
100# a simple configure script to test a single macro.
101# TESTNAME is the name of the macro being tested.
102# CONTENTS is the body of the configure script to create and test.
103proc autoconf_test {testname contents} {
104 if ![autoconf_remove $testname] {
105 return 0
106 }
107 if ![autoconf_create $testname "$contents"] {
108 return 0
109 }
110 if ![autoconf_start_plus $testname] {
111 autoconf_remove $testname
112 return 0
113 }
114 if ![autoconf_load_plus $testname] {
115 autoconf_remove $testname
116 return 0
117 }
118 if ![autoconf_remove $testname] {
119 return 0
120 }
121
122 pass "$testname"
123 return 1
124}
Note: See TracBrowser for help on using the repository browser.