Escape "-" in SYNOPSIS. Thanks to Bas van Gompel for noticing this
[findutils.git] / locate / testsuite / config / unix.exp
blob86be9ae60a3eac5d6e7c379e0633b0a9352a5a85
1 # -*- TCL -*-
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 # USA.
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
36 set env(PRUNEFS) ""
37 global UPDATEDB
38 # look for UPDATEDB
39 if ![info exists UPDATEDB] {
40 set UPDATEDB [findfile $base_dir/../updatedb $base_dir/../updatedb [transform updatedb]]
41 verbose "UPDATEDB defaulting to $UPDATEDB" 2
44 global UPDATEDBFLAGS
45 if ![info exists UPDATEDBFLAGS] then {
46 set UPDATEDBFLAGS ""
49 global LOCATE
50 # look for LOCATE
51 if ![info exists LOCATE] {
52 set LOCATE [findfile $base_dir/../locate $base_dir/../locate [transform locate]]
53 verbose "LOCATE defaulting to $LOCATE" 2
56 global LOCATEFLAGS
57 if ![info exists LOCATEFLAGS] then {
58 set LOCATEFLAGS ""
61 # Called by runtest.
62 # Extract and print the version number of locate.
63 proc locate_version {} {
64 global UPDATEDB
65 global UPDATEDBFLAGS
66 global LOCATE
67 global LOCATEFLAGS
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"
74 } else {
75 warning "cannot get version from $tmp."
77 } else {
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 ""}} {
86 global verbose
87 global LOCATE
88 global LOCATEFLAGS
89 global UPDATEDB
90 global UPDATEDBFLAGS
91 global comp_output
93 if {[which $UPDATEDB] == 0} then {
94 error "$UPDATEDB, program does not exist"
95 exit 1
97 if {[which $LOCATE] == 0} then {
98 error "$LOCATE, program does not exist"
99 exit 1
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"
111 } else {
112 set updatedb_infile /dev/null
114 if {"$locate_infile" != ""} then {
115 set locate_infile "[file dirname [file dirname $testbase]]/inputs/$locate_infile"
116 } else {
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"
124 if $verbose>1 then {
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"
129 if $verbose>1 then {
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"
137 if $verbose>1 then {
138 send_user "$comp_output\n"
140 if $fail_good then {
141 pass "$testname"
142 } else {
143 fail "$testname, $comp_output"
145 return
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
154 #puts $diffout
155 fail "$testname, $cmpout"
156 return
158 } else {
159 if {[file size locate.out] != 0} then {
160 fail "$testname, output should be empty"
161 return
164 pass "$testname"
165 catch "exec rm -rf tmp"
168 # Called by runtest.
169 # Clean up (remove temporary files) before runtest exits.
170 proc locate_exit {} {
171 catch "exec rm -f locate.out"
174 # Called by runtest.
175 # Extract and print the version number of updatedb.
176 proc updatedb_version {} {
177 global UPDATEDB
178 global UPDATEDBFLAGS
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"
185 } else {
186 warning "cannot get version from $tmp."
188 } else {
189 warning "$UPDATEDB, program does not exist"