2 # Test
-specific TCL procedures required by DejaGNU.
3 # Copyright
(C
) 1994 Free Software Foundation
, Inc.
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.
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.
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.
, 9 Temple Place
- Suite
330, Boston
, MA
02111-1307,
21 # Modified by David MacKenzie
<djm@gnu.ai.mit.edu
> from the gcc files
22 # written by Rob Savoye
<rob@cygnus.com
>.
25 # use the local version of find
for updatedb
27 # We normalise
(normalize
for those over the water
) pathnames
28 # because the updatedb
shell script uses
"cd", which means that
29 #
any relative paths no longer point where we thought they did.
30 set env
(find
) [file normalize
"../../find/find"]
32 # use the local help commands
for updatedb
33 set env
(LIBEXECDIR
) [file normalize ..
]
35 #
do not ignore
any file systems
for this test
39 if ![info exists UPDATEDB
] {
40 set UPDATEDB
[findfile $base_dir
/..
/updatedb $base_dir
/..
/updatedb
[transform updatedb
]]
41 verbose
"UPDATEDB defaulting to $UPDATEDB" 2
45 if ![info exists UPDATEDBFLAGS
] then {
51 if ![info exists LOCATE
] {
52 set LOCATE
[findfile $base_dir
/..
/locate $base_dir
/..
/locate
[transform locate
]]
53 verbose
"LOCATE defaulting to $LOCATE" 2
57 if ![info exists LOCATEFLAGS
] then {
62 # Extract and print the version number of locate.
63 proc locate_version
{} {
69 if {[which $LOCATE
] != 0} then {
70 set tmp
[ eval exec $LOCATE $LOCATEFLAGS
--version
</dev
/null
]
71 regexp
"version.*$" $tmp version
72 if [info exists version
] then {
73 clone_output
"[which $LOCATE] $version\n"
75 warning
"cannot get version from $tmp."
78 warning
"$LOCATE, program does not exist"
82 # Run locate and leave the output in $comp_output.
83 # Called by individual test scripts.
84 proc locate_start
{ passfail updatedb_options locate_options
85 {updatedb_infile
""} {locate_infile ""}} {
93 if {[which $UPDATEDB
] == 0} then {
94 error
"$UPDATEDB, program does not exist"
97 if {[which $LOCATE
] == 0} then {
98 error
"$LOCATE, program does not exist"
102 set fail_good
[string match
"f*" $passfail]
104 set scriptname
[uplevel
{info script
}]
105 set testbase
[file rootname $scriptname
]
106 set testname
[file tail $testbase
]
108 set outfile "$testbase.xo"
109 if {"$updatedb_infile" != ""} then {
110 set updatedb_infile
"[file dirname [file dirname $testbase]]/inputs/$updatedb_infile"
112 set updatedb_infile
/dev
/null
114 if {"$locate_infile" != ""} then {
115 set locate_infile
"[file dirname [file dirname $testbase]]/inputs/$locate_infile"
117 set locate_infile
/dev
/null
120 catch
"exec rm -f locate.out"
122 set updatedb_cmd
"$UPDATEDB $UPDATEDBFLAGS $updatedb_options < $updatedb_infile"
123 send_log
"$updatedb_cmd\n"
125 send_user
"Spawning \"$updatedb_cmd\"\n"
127 set locate_cmd
"$LOCATE $LOCATEFLAGS $locate_options < $locate_infile > locate.out"
128 send_log
"$locate_cmd\n"
130 send_user
"Spawning \"$locate_cmd\"\n"
133 catch
"exec $updatedb_cmd" comp_output
134 catch
"exec $locate_cmd" comp_output
135 if {$comp_output
!= ""} then {
136 send_log
"$comp_output\n"
138 send_user
"$comp_output\n"
143 fail
"$testname, $comp_output"
148 if [file
exists $
outfile] then {
149 set cmp_cmd
"cmp locate.out $outfile"
150 send_log
"$cmp_cmd\n"
151 catch
"exec $cmp_cmd" cmpout
152 if {$cmpout
!= ""} then {
153 #catch
"exec diff locate.out $outfile" diffout
155 fail
"$testname, $cmpout"
159 if {[file size locate.out
] != 0} then {
160 fail
"$testname, output should be empty"
165 catch
"exec rm -rf tmp"
169 # Clean up
(remove temporary files
) before runtest exits.
170 proc locate_exit
{} {
171 catch
"exec rm -f locate.out"
175 # Extract and print the version number of updatedb.
176 proc updatedb_version
{} {
180 if {[which $UPDATEDB
] != 0} then {
181 set tmp
[ eval exec $UPDATEDB $UPDATEDBFLAGS
--version
</dev
/null
]
182 regexp
"version.*$" $tmp version
183 if [info exists version
] then {
184 clone_output
"[which $UPDATEDB] $version\n"
186 warning
"cannot get version from $tmp."
189 warning
"$UPDATEDB, program does not exist"