home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / A / FIND / FINDUTIL.1 / FINDUTIL / findutils-4.1 / testsuite / config / unix.exp
Encoding:
Text File  |  1994-11-03  |  2.9 KB  |  110 lines

  1. # -*- TCL -*-
  2. # Test-specific TCL procedures required by DejaGNU.
  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. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  
  17. # Modified by David MacKenzie <djm@gnu.ai.mit.edu> from the gcc files
  18. # written by Rob Savoye <rob@cygnus.com>.
  19.  
  20.  
  21. # Called by runtest.
  22. # Extract and print the version number of xargs.
  23. proc xargs_version {} {
  24.     global XARGS
  25.     global XARGSFLAGS
  26.  
  27.     if {[which $XARGS] != 0} then {
  28.     set tmp [ eval exec $XARGS $XARGSFLAGS --version </dev/null ]
  29.     regexp "version.*$" $tmp version
  30.     if [info exists version] then {
  31.         clone_output "[which $XARGS] $version\n"
  32.     } else {
  33.         warning "cannot get version from $tmp."
  34.     }
  35.     } else {
  36.     warning "$XARGS, program does not exist"
  37.     }
  38. }
  39.  
  40. # Run xargs and leave the output in $comp_output.
  41. # Called by individual test scripts.
  42. proc xargs_start { passfail options infile } {
  43.     global verbose
  44.     global XARGS
  45.     global XARGSFLAGS
  46.     global comp_output
  47.  
  48.     if {[which $XARGS] == 0} then {
  49.     error "$XARGS, program does not exist"
  50.     exit 1
  51.     }
  52.  
  53.     set fail_good [string match "f*" $passfail]
  54.  
  55.     set scriptname [uplevel {info script}]
  56.     set testbase [file rootname $scriptname]
  57.     set testname [file tail $testbase]
  58.  
  59.     set outfile "$testbase.xo"
  60.     if {$infile != ""} then {
  61.     set infile "[file dirname [file dirname $testbase]]/inputs/$infile"
  62.     } else {
  63.     set infile /dev/null
  64.     }
  65.  
  66.     set cmd "$XARGS $XARGSFLAGS $options < $infile > xargs.out"
  67.     send_log "$cmd\n"
  68.     if $verbose>1 then {
  69.     send_user "Spawning \"$cmd\"\n"
  70.     }
  71.  
  72.     catch "exec $cmd" comp_output
  73.     if {$comp_output != ""} then {
  74.     send_log "$comp_output\n"
  75.     if $verbose>1 then {
  76.         send_user "$comp_output\n"
  77.     }
  78.     if $fail_good then {
  79.         pass "$testname"
  80.     } else {
  81.         fail "$testname, $comp_output"
  82.     }
  83.     return
  84.     }
  85.  
  86.     if [file exists $outfile] then {
  87.     set cmp_cmd "cmp xargs.out $outfile"
  88.     send_log "$cmp_cmd\n"
  89.     catch "exec $cmp_cmd" cmpout
  90.     if {$cmpout != ""} then {
  91.         fail "$testname, $cmpout"
  92.         return
  93.     }
  94.     } else {
  95.     if {[file size xargs.out] != 0} then {
  96.         fail "$testname, output should be empty"
  97.         return
  98.     }
  99.     }
  100.     pass "$testname"
  101. }
  102.  
  103. # Called by runtest.
  104. # Clean up (remove temporary files) before runtest exits.
  105. proc xargs_exit {} {
  106.     catch "exec rm -f xargs.out"
  107. }
  108.