Changeset 1993 for trunk/src/kmk/tests/test_driver.pl
- Timestamp:
- Oct 29, 2008, 1:37:51 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/tests/test_driver.pl
r1973 r1993 7 7 # 8 8 # 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. 10 10 # This file is part of GNU Make. 11 11 # 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. 15 16 # 16 17 # 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. 19 21 # 20 22 # 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/>. 23 24 24 25 … … 29 30 # variables and then calls &toplevel, which does all the real work. 30 31 31 # $Id: test_driver.pl,v 1.2 1 2007/03/20 03:02:26psmith Exp $32 # $Id: test_driver.pl,v 1.24 2007/11/04 21:54:02 psmith Exp $ 32 33 33 34 … … 48 49 # Yeesh. This whole test environment is such a hack! 49 50 $test_passed = 1; 51 52 53 # Timeout in seconds. If the test takes longer than this we'll fail it. 54 $test_timeout = 5; 50 55 51 56 … … 681 686 } else { 682 687 # See if it is a slash or CRLF problem 683 local ($answer_mod ) = $answer;688 local ($answer_mod, $slurp_mod) = ($answer, $slurp); 684 689 685 690 $answer_mod =~ tr,\\,/,; 686 691 $answer_mod =~ s,\r\n,\n,gs; 687 692 688 $slurp =~ tr,\\,/,; 689 $slurp =~ s,\r\n,\n,gs; 690 691 $answer_matched = ($slurp eq $answer_mod); 693 $slurp_mod =~ tr,\\,/,; 694 $slurp_mod =~ s,\r\n,\n,gs; 695 696 $answer_matched = ($slurp_mod eq $answer_mod); 697 698 # If it still doesn't match, see if the answer might be a regex. 699 if (!$answer_matched && $answer =~ m,^/(.+)/$,) { 700 $answer_matched = ($slurp =~ /$1/); 701 if (!$answer_matched && $answer_mod =~ m,^/(.+)/$,) { 702 $answer_matched = ($slurp_mod =~ /$1/); 703 } 704 } 692 705 } 693 706 … … 790 803 } 791 804 792 # run one command (passed as a list of arg 0 - n), returning 0 on success 793 # and nonzero on failure. 794 795 sub run_command 796 { 797 local ($code); 805 # This runs a command without any debugging info. 806 sub _run_command 807 { 808 my $code; 798 809 799 810 # We reset this before every invocation. On Windows I think there is only … … 802 813 resetENV(); 803 814 815 eval { 816 local $SIG{ALRM} = sub { die "timeout\n"; }; 817 alarm $test_timeout; 818 $code = system @_; 819 alarm 0; 820 }; 821 if ($@) { 822 # The eval failed. If it wasn't SIGALRM then die. 823 $@ eq "timeout\n" or die; 824 825 # Timed out. Resend the alarm to our process group to kill the children. 826 $SIG{ALRM} = 'IGNORE'; 827 kill -14, $$; 828 $code = 14; 829 } 830 831 return $code; 832 } 833 834 # run one command (passed as a list of arg 0 - n), returning 0 on success 835 # and nonzero on failure. 836 837 sub run_command 838 { 804 839 print "\nrun_command: @_\n" if $debug; 805 $code = system @_;806 print "run_command : \"@_\"returned $code.\n" if $debug;840 my $code = _run_command(@_); 841 print "run_command returned $code.\n" if $debug; 807 842 808 843 return $code; … … 816 851 sub run_command_with_output 817 852 { 818 local ($filename) = shift; 819 local ($code); 820 821 # We reset this before every invocation. On Windows I think there is only 822 # one environment, not one per process, so I think that variables set in 823 # test scripts might leak into subsequent tests if this isn't reset--??? 824 resetENV(); 825 853 my $filename = shift; 854 855 print "\nrun_command_with_output($filename): @_\n" if $debug; 826 856 &attach_default_output ($filename); 827 $code = system @_;857 my $code = _run_command(@_); 828 858 &detach_default_output; 829 830 print "run_command_with_output: '@_' returned $code.\n" if $debug; 859 print "run_command_with_output returned $code.\n" if $debug; 831 860 832 861 return $code;
Note:
See TracChangeset
for help on using the changeset viewer.