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.
, 675 Mass Ave
, Cambridge
, MA
02139, USA.
19 # Modified by David MacKenzie
<djm@gnu.ai.mit.edu
> from the gcc files
20 # written by Rob Savoye
<rob@cygnus.com
>.
23 # use the local version of find
for updatedb
24 set env
(find
) ..
/..
/find
/find
25 # use the local help commands
for updatedb
26 set env
(LIBEXECDIR
) ..
29 if ![info exists UPDATEDB
] {
30 set UPDATEDB
[findfile $base_dir
/..
/updatedb $base_dir
/..
/updatedb
[transform updatedb
]]
31 verbose
"UPDATEDB defaulting to $UPDATEDB" 2
35 if ![info exists UPDATEDBFLAGS
] then {
41 if ![info exists LOCATE
] {
42 set LOCATE
[findfile $base_dir
/..
/locate $base_dir
/..
/locate
[transform locate
]]
43 verbose
"LOCATE defaulting to $LOCATE" 2
47 if ![info exists LOCATEFLAGS
] then {
52 # Extract and print the version number of locate.
53 proc locate_version
{} {
59 if {[which $LOCATE
] != 0} then {
60 set tmp
[ eval exec $LOCATE $LOCATEFLAGS
--version
</dev
/null
]
61 regexp
"version.*$" $tmp version
62 if [info exists version
] then {
63 clone_output
"[which $LOCATE] $version\n"
65 warning
"cannot get version from $tmp."
68 warning
"$LOCATE, program does not exist"
72 # Run locate and leave the output in $comp_output.
73 # Called by individual test scripts.
74 proc locate_start
{ passfail updatedb_options locate_options
75 {updatedb_infile
""} {locate_infile ""}} {
83 if {[which $UPDATEDB
] == 0} then {
84 error
"$UPDATEDB, program does not exist"
87 if {[which $LOCATE
] == 0} then {
88 error
"$LOCATE, program does not exist"
92 set fail_good
[string match
"f*" $passfail]
94 set scriptname
[uplevel
{info script
}]
95 set testbase
[file rootname $scriptname
]
96 set testname
[file tail $testbase
]
98 set outfile "$testbase.xo"
99 if {"$updatedb_infile" != ""} then {
100 set updatedb_infile
"[file dirname [file dirname $testbase]]/inputs/$updatedb_infile"
102 set updatedb_infile
/dev
/null
104 if {"$locate_infile" != ""} then {
105 set locate_infile
"[file dirname [file dirname $testbase]]/inputs/$locate_infile"
107 set locate_infile
/dev
/null
110 catch
"exec rm -f locate.out"
112 set updatedb_cmd
"$UPDATEDB $UPDATEDBFLAGS $updatedb_options < $updatedb_infile"
113 send_log
"$updatedb_cmd\n"
115 send_user
"Spawning \"$updatedb_cmd\"\n"
117 set locate_cmd
"$LOCATE $LOCATEFLAGS $locate_options < $locate_infile > locate.out"
118 send_log
"$locate_cmd\n"
120 send_user
"Spawning \"$locate_cmd\"\n"
123 catch
"exec $updatedb_cmd" comp_output
124 catch
"exec $locate_cmd" comp_output
125 if {$comp_output
!= ""} then {
126 send_log
"$comp_output\n"
128 send_user
"$comp_output\n"
133 fail
"$testname, $comp_output"
138 if [file
exists $
outfile] then {
139 set cmp_cmd
"cmp locate.out $outfile"
140 send_log
"$cmp_cmd\n"
141 catch
"exec $cmp_cmd" cmpout
142 if {$cmpout
!= ""} then {
143 fail
"$testname, $cmpout"
147 if {[file size locate.out
] != 0} then {
148 fail
"$testname, output should be empty"
153 catch
"exec rm -rf tmp"
157 # Clean up
(remove temporary files
) before runtest exits.
158 proc locate_exit
{} {
159 catch
"exec rm -f locate.out"
163 # Extract and print the version number of updatedb.
164 proc updatedb_version
{} {
168 if {[which $UPDATEDB
] != 0} then {
169 set tmp
[ eval exec $UPDATEDB $UPDATEDBFLAGS
--version
</dev
/null
]
170 regexp
"version.*$" $tmp version
171 if [info exists version
] then {
172 clone_output
"[which $UPDATEDB] $version\n"
174 warning
"cannot get version from $tmp."
177 warning
"$UPDATEDB, program does not exist"