Merged changes made for version 4.1.20 onto the trunk
[findutils.git] / find / testsuite / config / unix.exp
blob920f66112d468c3ce41afd096df1f4e5ea6091df
1 # -*- TCL -*-
2 # Test-specific TCL procedures required by DejaGNU.
3 # Copyright (C) 2000 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., 9 Temple Place - Suite 330, Boston, MA 02111-1307,
18 # USA.
20 # Modified by Kevin Dalley <kevind@rahul.net> from the xargs files.
21 # Modified by David MacKenzie <djm@gnu.ai.mit.edu> from the gcc files
22 # written by Rob Savoye <rob@cygnus.com>.
25 global FIND
26 # look for FIND
27 if ![info exists FIND] {
28 set FIND [findfile $base_dir/../find $base_dir/../find [transform find]]
29 verbose "FIND defaulting to $FIND" 2
32 global FINDFLAGS
33 if ![info exists FINDFLAGS] then {
34 set FINDFLAGS ""
37 # Called by runtest.
38 # Extract and print the version number of find.
39 proc find_version {} {
40 global FIND
41 global FINDFLAGS
43 if {[which $FIND] != 0} then {
44 set tmp [ eval exec $FIND $FINDFLAGS --version </dev/null ]
45 regexp "version.*$" $tmp version
46 if [info exists version] then {
47 clone_output "[which $FIND] $version\n"
48 } else {
49 warning "cannot get version from $tmp."
51 } else {
52 warning "$FIND, program does not exist"
56 # Run find and leave the output in $comp_output.
57 # Called by individual test scripts.
58 proc find_start { passfail options {infile ""}} {
59 global verbose
60 global FIND
61 global FINDFLAGS
62 global comp_output
64 if {[which $FIND] == 0} then {
65 error "$FIND, program does not exist"
66 exit 1
69 set fail_good [string match "f*" $passfail]
71 set scriptname [uplevel {info script}]
72 set testbase [file rootname $scriptname]
73 set testname [file tail $testbase]
75 set outfile "$testbase.xo"
76 if {$infile != ""} then {
77 set infile "[file dirname [file dirname $testbase]]/inputs/$infile"
78 } else {
79 set infile /dev/null
82 set cmd "$FIND $FINDFLAGS $options < $infile > find.out"
83 send_log "$cmd\n"
84 if $verbose>1 then {
85 send_user "Spawning \"$cmd\"\n"
88 catch "exec $cmd" comp_output
89 if {$comp_output != ""} then {
90 send_log "$comp_output\n"
91 if $verbose>1 then {
92 send_user "$comp_output\n"
94 if $fail_good then {
95 pass "$testname"
96 } else {
97 fail "$testname, $comp_output"
99 return
102 if [file exists $outfile] then {
103 set cmp_cmd "cmp find.out $outfile"
104 send_log "$cmp_cmd\n"
105 catch "exec $cmp_cmd" cmpout
106 if {$cmpout != ""} then {
107 fail "$testname, $cmpout"
108 return
110 } else {
111 if {[file size find.out] != 0} then {
112 fail "$testname, output should be empty"
113 return
116 pass "$testname"
119 # Called by runtest.
120 # Clean up (remove temporary files) before runtest exits.
121 proc find_exit {} {
122 catch "exec rm -f find.out"
123 exec echo hello