VirtualBox

Ignore:
Timestamp:
Oct 28, 2008 11:02:45 PM (16 years ago)
Author:
bird
Message:

Load gnumake-2008-10-28-CVS into vendor/gnumake/current.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current/tests/test_driver.pl

    r900 r1989  
    77#
    88# Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
    9 # 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
     9# 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    1010# This file is part of GNU Make.
    1111#
    12 # GNU Make is free software; you can redistribute it and/or modify it under the
    13 # terms of the GNU General Public License as published by the Free Software
    14 # Foundation; either version 2, or (at your option) any later version.
     12# GNU Make is free software; you can redistribute it and/or modify it under
     13# the terms of the GNU General Public License as published by the Free Software
     14# Foundation; either version 3 of the License, or (at your option) any later
     15# version.
    1516#
    1617# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
    17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     18# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     19# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
     20# details.
    1921#
    2022# You should have received a copy of the GNU General Public License along with
    21 # GNU Make; see the file COPYING.  If not, write to the Free Software
    22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     23# this program.  If not, see <http://www.gnu.org/licenses/>.
    2324
    2425
     
    2930# variables and then calls &toplevel, which does all the real work.
    3031
    31 # $Id: test_driver.pl,v 1.21 2007/03/20 03:02:26 psmith Exp $
     32# $Id: test_driver.pl,v 1.24 2007/11/04 21:54:02 psmith Exp $
    3233
    3334
     
    4849# Yeesh.  This whole test environment is such a hack!
    4950$test_passed = 1;
     51
     52
     53# Timeout in seconds.  If the test takes longer than this we'll fail it.
     54$test_timeout = 5;
    5055
    5156
     
    657662  } else {
    658663    # See if it is a slash or CRLF problem
    659     local ($answer_mod) = $answer;
     664    local ($answer_mod, $slurp_mod) = ($answer, $slurp);
    660665
    661666    $answer_mod =~ tr,\\,/,;
    662667    $answer_mod =~ s,\r\n,\n,gs;
    663668
    664     $slurp =~ tr,\\,/,;
    665     $slurp =~ s,\r\n,\n,gs;
    666 
    667     $answer_matched = ($slurp eq $answer_mod);
     669    $slurp_mod =~ tr,\\,/,;
     670    $slurp_mod =~ s,\r\n,\n,gs;
     671
     672    $answer_matched = ($slurp_mod eq $answer_mod);
     673
     674    # If it still doesn't match, see if the answer might be a regex.
     675    if (!$answer_matched && $answer =~ m,^/(.+)/$,) {
     676      $answer_matched = ($slurp =~ /$1/);
     677      if (!$answer_matched && $answer_mod =~ m,^/(.+)/$,) {
     678          $answer_matched = ($slurp_mod =~ /$1/);
     679      }
     680    }
    668681  }
    669682
     
    766779}
    767780
    768 # run one command (passed as a list of arg 0 - n), returning 0 on success
    769 # and nonzero on failure.
    770 
    771 sub run_command
    772 {
    773   local ($code);
     781# This runs a command without any debugging info.
     782sub _run_command
     783{
     784  my $code;
    774785
    775786  # We reset this before every invocation.  On Windows I think there is only
     
    778789  resetENV();
    779790
     791  eval {
     792      local $SIG{ALRM} = sub { die "timeout\n"; };
     793      alarm $test_timeout;
     794      $code = system @_;
     795      alarm 0;
     796  };
     797  if ($@) {
     798      # The eval failed.  If it wasn't SIGALRM then die.
     799      $@ eq "timeout\n" or die;
     800
     801      # Timed out.  Resend the alarm to our process group to kill the children.
     802      $SIG{ALRM} = 'IGNORE';
     803      kill -14, $$;
     804      $code = 14;
     805  }
     806
     807  return $code;
     808}
     809
     810# run one command (passed as a list of arg 0 - n), returning 0 on success
     811# and nonzero on failure.
     812
     813sub run_command
     814{
    780815  print "\nrun_command: @_\n" if $debug;
    781   $code = system @_;
    782   print "run_command: \"@_\" returned $code.\n" if $debug;
     816  my $code = _run_command(@_);
     817  print "run_command returned $code.\n" if $debug;
    783818
    784819  return $code;
     
    792827sub run_command_with_output
    793828{
    794   local ($filename) = shift;
    795   local ($code);
    796 
    797   # We reset this before every invocation.  On Windows I think there is only
    798   # one environment, not one per process, so I think that variables set in
    799   # test scripts might leak into subsequent tests if this isn't reset--???
    800   resetENV();
    801 
     829  my $filename = shift;
     830
     831  print "\nrun_command_with_output($filename): @_\n" if $debug;
    802832  &attach_default_output ($filename);
    803   $code = system @_;
     833  my $code = _run_command(@_);
    804834  &detach_default_output;
    805 
    806   print "run_command_with_output: '@_' returned $code.\n" if $debug;
     835  print "run_command_with_output returned $code.\n" if $debug;
    807836
    808837  return $code;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette