Ignore:
Timestamp:
May 16, 2005, 6:54:02 PM (20 years ago)
Author:
bird
Message:

Current make snaphot, 2005-05-16.

Location:
branches/GNU/src/gmake
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gmake

    • Property svn:ignore
      •  

        old new  
        3434README.DOS
        3535README.W32
         36README.OS2
        3637aclocal.m4
        3738autom4te.cache
  • branches/GNU/src/gmake/tests/ChangeLog

    r153 r280  
     12005-05-13  Paul D. Smith  <psmith@gnu.org>
     2
     3        * scripts/features/conditionals: Add tests for the new if... else
     4        if... endif syntax.
     5
     62005-05-03  Paul D. Smith  <psmith@gnu.org>
     7
     8        * scripts/variables/DEFAULT_GOAL: Rename DEFAULT_TARGET to
     9        DEFAULT_GOAL.
     10
     112005-05-02  Paul D. Smith  <psmith@gnu.org>
     12
     13        * scripts/features/parallelism: Add a test for exporting recursive
     14        variables containing $(shell ) calls.  Rewrite this script to use
     15        run_make_test() everywhere.
     16
     172005-04-07  Paul D. Smith  <psmith@gnu.org>
     18
     19        * scripts/targets/SECONDARY: Add a test for Savannah bug #12331.
     20
     212005-03-15  Boris Kolpackov  <boris@kolpackov.net>
     22
     23        * scripts/variables/automatic: Add a test for Savannah bug #12320.
     24
     252005-03-10  Boris Kolpackov  <boris@kolpackov.net>
     26
     27        * scripts/features/patternrules: Add a test for Savannah bug #12267.
     28
     292005-03-09  Boris Kolpackov  <boris@kolpackov.net>
     30
     31        * scripts/variables/DEFAULT_TARGET: Add a test for Savannah
     32        bug #12266.
     33
     342005-03-04  Boris Kolpackov  <boris@kolpackov.net>
     35
     36        * scripts/features/patternrules: Add a test for Savannah bug #12202.
     37
     382005-03-03  Boris Kolpackov  <boris@kolpackov.net>
     39
     40        * scripts/features/se_implicit: Add a test for stem
     41        termination bug. Add a test for stem triple-expansion bug.
     42
     43        * scripts/features/se_statpat: Add a test for stem
     44        triple-expansion bug.
     45
     46        * scripts/features/statipattrules: Change test #4 to reflect
     47        new way empty prerequisite list is handled.
     48
     49
     502005-03-01  Boris Kolpackov  <boris@kolpackov.net>
     51
     52        * scripts/features/statipattrules: Add a test for
     53        Savannah bug #12180.
     54
     552005-02-28  Paul D. Smith  <psmith@gnu.org>
     56
     57        * scripts/options/dash-q: Add a test for Savannah bug # 7144.
     58
     59        * scripts/options/symlinks: New file to test checking of symlink
     60        timestamps.  Can't use filename dash-L because it conflicts with
     61        dash-l on case-insensitive filesystems.
     62
     63        * scripts/variables/MAKEFILE_LIST, scripts/variables/MFILE_LIST:
     64        Rename MAKEFILE_LIST test to MFILE_LIST, for systems that need 8.3
     65        unique filenames.
     66
     672005-02-28  Boris Kolpackov  <boris@kolpackov.net>
     68
     69        * scripts/variables/DEFAULT_TARGET: Test the .DEFAULT_TARGET
     70        special variable.
     71
     722005-02-27  Boris Kolpackov  <boris@kolpackov.net>
     73
     74        * scripts/features/se_explicit: Test the second expansion in
     75        explicit rules.
     76        * scripts/features/se_implicit: Test the second expansion in
     77        implicit rules.
     78        * scripts/features/se_statpat: Test the second expansion in
     79        static pattern rules.
     80        * scripts/variables/automatic: Fix to work with the second
     81        expansion.
     82
     83        * scripts/misc/general4: Add a test for bug #12091.
     84
     852005-02-27  Paul D. Smith  <psmith@gnu.org>
     86
     87        * scripts/functions/eval: Check that eval of targets within
     88        command scripts fails.  See Savannah bug # 12124.
     89
     902005-02-26  Paul D. Smith  <psmith@gnu.org>
     91
     92        * test_driver.pl (compare_output): If a basic comparison of the
     93        log and answer doesn't match, try harder: change all backslashes
     94        to slashes and all CRLF to LF.  This helps on DOS/Windows systems.
     95
     962005-02-09  Paul D. Smith  <psmith@gnu.org>
     97
     98        * scripts/features/recursion: Test command line variable settings:
     99        only one instance of a given variable should be provided.
     100
     1012004-11-30  Boris Kolpackov  <boris@kolpackov.net>
     102
     103        * tests/scripts/functions/abspath: New file: test `abspath'
     104        built-in function.
     105
     106        * tests/scripts/functions/realpath: New file: test `realpath'
     107        built-in function.
     108
     1092004-11-28  Paul D. Smith  <psmith@gnu.org>
     110
     111        * scripts/options/dash-C [WINDOWS32]: Add a test for bug #10252;
     112        this doesn't really test anything useful in UNIX but...
     113
     114        * scripts/variables/SHELL: New file: test proper handling of SHELL
     115        according to POSIX rules.  Fixes bug #1276.
     116
     1172004-10-21  Boris Kolpackov  <boris@kolpackov.net>
     118
     119        * scripts/functions/word: Test $(firstword ) and $(lastword ).
     120
     1212004-10-05  Boris Kolpackov  <boris@kolpackov.net>
     122
     123        * scripts/features/patspecific_vars: Test simple/recursive
     124        variable expansion.
     125
     1262004-09-28  Boris Kolpackov  <boris@kolpackov.net>
     127
     128        * scripts/features/include: Test dontcare flag inheritance
     129        when rebuilding makefiles.
     130
     1312004-09-27  Boris Kolpackov  <boris@kolpackov.net>
     132
     133        * scripts/features/patspecific_vars: Test exported variables.
     134
     1352004-09-22  Paul D. Smith  <psmith@gnu.org>
     136
     137        * run_make_tests.pl (run_make_test): Don't add newlines to the
     138        makestring or answer if they are completely empty.
     139
     140        * scripts/features/patternrules: Rename from implicit_prereq_eval.
     141
     142        * scripts/test_template: Rework the template.
     143
     1442004-09-21  Boris Kolpackov  <boris@kolpackov.net>
     145
     146        * run_make_tests.pl: Change `#!/usr/local/bin/perl' to be
     147        `#!/usr/bin/env perl'.
     148
     149        * scripts/features/implicit_prereq_eval: Test implicit rule
     150        prerequisite evaluation code.
     151
     1522004-09-21  Paul D. Smith  <psmith@gnu.org>
     153
     154        * run_make_tests.pl (run_make_test): Enhance to allow the make
     155        string to be undef: in that case it reuses the previous make
     156        string.  Allows multiple tests on the same makefile.
     157
     158        * scripts/variables/flavors: Add some tests for prefix characters
     159        interacting with define/endef variables.
     160
     1612004-09-20  Paul D. Smith  <psmith@gnu.org>
     162
     163        * scripts/functions/substitution: Rewrite to use run_make_test()
     164        interface, and add test for substitution failures reported by
     165        Markus Mauhart <qwe123@chello.at>.
     166
     1672004-03-22  Paul D. Smith  <psmith@gnu.org>
     168
     169        * test_driver.pl (run_each_test, toplevel, compare_output): Change
     170        to track both the testing categories _AND_ the number of
     171        individual tests, and report both sets of numbers.
     172
    11732004-02-21  Paul D. Smith  <psmith@gnu.org>
    2174
  • branches/GNU/src/gmake/tests/run_make_tests.pl

    r53 r280  
    1 #!/usr/local/bin/perl
     1#!/usr/bin/env perl
    22# -*-perl-*-
    33
     
    1313
    1414$valgrind = 0;              # invoke make with valgrind
     15$pure_log = undef;
    1516
    1617require "test_driver.pl";
     
    3839   }
    3940
    40 # This doesn't work--it _should_!  Someone needs to fix this badly.
     41# This doesn't work--it _should_!  Someone badly needs to fix this.
    4142#
    4243#   elsif ($option =~ /^-work([-_]?dir)?$/)
     
    4950}
    5051
    51 sub run_make_with_options
    52 {
    53    local ($filename,$options,$logname,$expected_code) = @_;
    54    local($code);
    55    local($command) = $make_path;
    56 
    57    $expected_code = 0 unless defined($expected_code);
    58 
    59    if ($filename)
    60    {
    61       $command .= " -f $filename";
    62    }
    63 
    64    if ($options)
    65    {
    66       $command .= " $options";
    67    }
    68 
    69    if ($valgrind) {
    70      print VALGRIND "\n\nExecuting: $command\n";
    71    }
    72 
    73    $code = &run_command_with_output($logname,$command);
    74 
    75    # Check to see if we have Purify errors.  If so, keep the logfile.
    76    # For this to work you need to build with the Purify flag -exit-status=yes
    77 
    78    if ($pure_log && -f $pure_log) {
    79      if ($code & 0x7000) {
    80        $code &= ~0x7000;
    81 
    82        # If we have a purify log, save it
    83        $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : "");
    84        print("Renaming purify log file to $tn\n") if $debug;
    85        rename($pure_log, "$tn")
    86          || die "Can't rename $log to $tn: $!\n";
    87        ++$purify_errors;
    88      }
    89      else {
    90        unlink($pure_log);
    91      }
    92    }
    93 
    94    if ($code != $expected_code)
    95    {
    96       print "Error running $make_path ($code): $command\n";
    97       $test_passed = 0;
    98       # If it's a SIGINT, stop here
    99       if ($code & 127) {
    100         print STDERR "\nCaught signal ".($code & 127)."!\n";
    101         exit($code);
    102       }
    103       return 0;
    104    }
    105 
    106    if ($profile & $vos)
    107    {
    108       system "add_profile $make_path";
    109    }
    110 1;
     52
     53# This is an "all-in-one" function.  Arguments are as follows:
     54#
     55#  [0] (string):  The makefile to be tested.  undef means use the last one.
     56#  [1] (string):  Arguments to pass to make.
     57#  [2] (string):  Answer we should get back.
     58#  [3] (integer): Exit code we expect.  A missing code means 0 (success)
     59
     60$old_makefile = undef;
     61
     62sub run_make_test
     63{
     64  local ($makestring, $options, $answer, $err_code) = @_;
     65
     66  # If the user specified a makefile string, create a new makefile to contain
     67  # it.  If the first value is not defined, use the last one (if there is
     68  # one).
     69
     70  if (! defined $makestring) {
     71    defined $old_makefile
     72      || die "run_make_test(undef) invoked before run_make_test('...')\n";
     73    $makefile = $old_makefile;
     74  } else {
     75    if (! defined($makefile)) {
     76      $makefile = &get_tmpfile();
     77    }
     78
     79    # Make sure it ends in a newline.
     80    $makestring && $makestring !~ /\n$/s and $makestring .= "\n";
     81
     82    # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
     83    # make
     84    $makestring =~ s/#MAKEFILE#/$makefile/g;
     85    $makestring =~ s/#MAKEPATH#/$mkpath/g;
     86    $makestring =~ s/#MAKE#/$make_name/g;
     87    $makestring =~ s/#PWD#/$pwd/g;
     88
     89    # Populate the makefile!
     90    open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n";
     91    print MAKEFILE $makestring;
     92    close(MAKEFILE) || die "Failed to write $makefile: $!\n";
     93  }
     94
     95  # Do the same processing on $answer as we did on $makestring.
     96
     97  $answer && $answer !~ /\n$/s and $answer .= "\n";
     98  $answer =~ s/#MAKEFILE#/$makefile/g;
     99  $answer =~ s/#MAKEPATH#/$mkpath/g;
     100  $answer =~ s/#MAKE#/$make_name/g;
     101  $answer =~ s/#PWD#/$pwd/g;
     102
     103  &run_make_with_options($makefile, $options, &get_logfile(0), $err_code);
     104  &compare_output($answer, &get_logfile(1));
     105
     106  $old_makefile = $makefile;
     107  $makefile = undef;
     108}
     109
     110# The old-fashioned way...
     111sub run_make_with_options {
     112  local ($filename,$options,$logname,$expected_code) = @_;
     113  local($code);
     114  local($command) = $make_path;
     115
     116  $expected_code = 0 unless defined($expected_code);
     117
     118  # Reset to reflect this one test.
     119  $test_passed = 1;
     120
     121  if ($filename) {
     122    $command .= " -f $filename";
     123  }
     124
     125  if ($options) {
     126    $command .= " $options";
     127  }
     128
     129  if ($valgrind) {
     130    print VALGRIND "\n\nExecuting: $command\n";
     131  }
     132
     133  $code = &run_command_with_output($logname,$command);
     134
     135  # Check to see if we have Purify errors.  If so, keep the logfile.
     136  # For this to work you need to build with the Purify flag -exit-status=yes
     137
     138  if ($pure_log && -f $pure_log) {
     139    if ($code & 0x7000) {
     140      $code &= ~0x7000;
     141
     142      # If we have a purify log, save it
     143      $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : "");
     144      print("Renaming purify log file to $tn\n") if $debug;
     145      rename($pure_log, "$tn")
     146        || die "Can't rename $log to $tn: $!\n";
     147      ++$purify_errors;
     148    } else {
     149      unlink($pure_log);
     150    }
     151  }
     152
     153  if ($code != $expected_code) {
     154    print "Error running $make_path (expected $expected_code; got $code): $command\n";
     155    $test_passed = 0;
     156    # If it's a SIGINT, stop here
     157    if ($code & 127) {
     158      print STDERR "\nCaught signal ".($code & 127)."!\n";
     159      exit($code);
     160    }
     161    return 0;
     162  }
     163
     164  if ($profile & $vos) {
     165    system "add_profile $make_path";
     166  }
     167
     168  1;
    111169}
    112170
     
    159217   # This is probably not specific enough.
    160218   #
    161    if ($osname =~ /Windows/i) {
     219   if ($osname =~ /Windows/i || $osname =~ /MINGW32/i) {
    162220     $port_type = 'W32';
    163221   }
     
    184242   # timestamps with second granularity (!!).  Change the sleep time
    185243   # needed to force a file to be considered "old".
    186    #
    187244   $wtime = $port_type eq 'UNIX' ? 1 : $port_type eq 'OS/2' ? 2 : 4;
     245
     246   print "Port type: $port_type\n" if $debug;
     247   print "Make path: $make_path\n" if $debug;
    188248
    189249   # Find the full pathname of Make.  For DOS systems this is more
    190250   # complicated, so we ask make itself.
    191 
    192251   $make_path = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
    193252   chop $make_path;
     
    227286   # Get Purify log info--if any.
    228287
    229    $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/;
    230    $pure_log = $1 || '';
    231    $pure_log =~ s/%v/$make_name/;
    232    $purify_errors = 0;
     288   if (exists $ENV{PURIFYOPTIONS}
     289       && $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/) {
     290     $pure_log = $1 || '';
     291     $pure_log =~ s/%v/$make_name/;
     292     $purify_errors = 0;
     293   }
    233294
    234295   $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`;
  • branches/GNU/src/gmake/tests/scripts/features/conditionals

    r153 r280  
    44$details = "Attempt various different flavors of GNU make conditionals.";
    55
    6 open(MAKEFILE,"> $makefile");
    7 
    8 # The Contents of the MAKEFILE ...
    9 
    10 print MAKEFILE <<'EOMAKE';
    11 objects = foo.obj
     6run_make_test('
    127arg1 = first
    138arg2 = second
     
    2318endif
    2419
    25 ifeq '$(arg2)' "$(arg5)"
     20ifeq \'$(arg2)\' "$(arg5)"
    2621        @echo arg2 equals arg5
    2722else
     
    2924endif
    3025
    31 ifneq '$(arg3)' '$(arg4)'
     26ifneq \'$(arg3)\' \'$(arg4)\'
    3227        @echo arg3 NOT equal arg4
    3328else
     
    4439else
    4540        @echo arg4 is NOT defined
    46 endif
    47 
    48 EOMAKE
    49 
    50 close(MAKEFILE);
    51 
    52 &run_make_with_options($makefile,"",&get_logfile,0);
    53 
    54 $answer = "arg1 NOT equal arg2
     41endif',
     42              '',
     43              'arg1 NOT equal arg2
    5544arg2 equals arg5
    5645arg3 NOT equal arg4
    5746variable is undefined
    58 arg4 is defined
    59 ";
    60 
    61 &compare_output($answer,&get_logfile(1));
     47arg4 is defined');
    6248
    6349
    6450# Test expansion of variables inside ifdef.
    6551
    66 $makefile2 = &get_tmpfile;
    67 
    68 open(MAKEFILE, "> $makefile2");
    69 
    70 print MAKEFILE <<'EOF';
    71 
     52run_make_test('
    7253foo = 1
    7354
     
    9374endif
    9475
    95 all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)
     76all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)',
     77              '',
     78              'DEF=yes DEF2=yes DEF3=yes');
    9679
    97 EOF
    9880
    99 close(MAKEFILE)
     81# Test all the different "else if..." constructs
    10082
    101 &run_make_with_options($makefile2,"",&get_logfile,0);
    102 $answer = "DEF=yes DEF2=yes DEF3=yes\n";
    103 &compare_output($answer,&get_logfile(1));
     83run_make_test('
     84arg1 = first
     85arg2 = second
     86arg3 = third
     87arg4 = cc
     88arg5 = fifth
     89
     90result =
     91
     92ifeq ($(arg1),$(arg2))
     93  result += arg1 equals arg2
     94else ifeq \'$(arg2)\' "$(arg5)"
     95  result += arg2 equals arg5
     96else ifneq \'$(arg3)\' \'$(arg3)\'
     97  result += arg3 NOT equal arg4
     98else ifndef arg5
     99  result += variable is undefined
     100else ifdef undefined
     101  result += arg4 is defined
     102else
     103  result += success
     104endif
     105
     106
     107all: ; @echo $(result)',
     108              '',
     109              'success');
     110
     111
     112# Test some random "else if..." construct nesting
     113
     114run_make_test('
     115arg1 = first
     116arg2 = second
     117arg3 = third
     118arg4 = cc
     119arg5 = second
     120
     121ifeq ($(arg1),$(arg2))
     122  $(info failed 1)
     123else ifeq \'$(arg2)\' "$(arg2)"
     124  ifdef undefined
     125    $(info failed 2)
     126  else
     127    $(info success)
     128  endif
     129else ifneq \'$(arg3)\' \'$(arg3)\'
     130  $(info failed 3)
     131else ifdef arg5
     132  $(info failed 4)
     133else ifdef undefined
     134  $(info failed 5)
     135else
     136  $(info failed 6)
     137endif
     138
     139.PHONY: all
     140all: ; @:',
     141              '',
     142              'success');
    104143
    105144
  • branches/GNU/src/gmake/tests/scripts/features/echoing

    r53 r280  
    5555
    5656&run_make_with_options($makefile,"clean",&get_logfile,0);
    57 $answer = "";
    58 &compare_output($answer,&get_logfile(1));
    59 
    60 if (-f $example)
    61 {
    62    $test_passed = 0;
     57if (-f $example) {
     58  $test_passed = 0;
    6359}
     60&compare_output('',&get_logfile(1));
    6461
    6562# TEST #3
  • branches/GNU/src/gmake/tests/scripts/features/errors

    r53 r280  
    5353&run_make_with_options($makefile,"",&get_logfile);
    5454
     55# If make acted as planned, it should ignore the error from the first
     56# command in the target and execute the second which deletes the file "foo"
     57# This file, therefore, should not exist if the test PASSES.
     58if (-f "foo") {
     59  $test_passed = 0;
     60}
     61
    5562# The output for this on VOS is too hard to replicate, so we only check it
    5663# on unix.
     
    5865{
    5966   &compare_output($answer,&get_logfile(1));
    60 }
    61 
    62 # If make acted as planned, it should ignore the error from the first
    63 # command in the target and execute the second which deletes the file "foo"
    64 # This file, therefore, should not exist if the test PASSES.
    65 if (-f "foo")
    66 {
    67    $test_passed = 0;
    6867}
    6968
     
    8180&run_make_with_options($makefile,"clean2 -i",&get_logfile);
    8281
    83 if (!$vos)
    84 {
     82if (-f "foo") {
     83  $test_passed = 0;
     84}
     85
     86if (!$vos) {
    8587   &compare_output($answer,&get_logfile(1));
    8688}
    8789
    88 if (-f "foo")
    89 {
    90    $test_passed = 0;
    91 }
    92 
    93901;
  • branches/GNU/src/gmake/tests/scripts/test_template

    r53 r280  
    1 $description = "The following test creates a makefile to ...
    2                      <FILL IN DESCRIPTION HERE> ";
     1#                                                                    -*-perl-*-
    32
     3$description = "<FILL IN SHORT DESCRIPTION HERE>";
    44$details = "<FILL IN DETAILS OF HOW YOU TEST WHAT YOU SAY YOU ARE TESTING>";
    55
    6 # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET
    7 # THE NAME OF THE MAKEFILE.  THIS INSURES CONSISTENCY AND KEEPS TRACK OF
    8 # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END.
    9 # EXAMPLE: $makefile2 = &get_tmpfile;
     6# Run a make test.  See the documentation of run_make_test() in
     7# run_make_tests.pl, but briefly the first argument is a string with the
     8# contents of a makefile to be tested, the second is a string containing the
     9# arguments to be passed to the make invocation, the third is a string
     10# containing the expected output.  The fourth is the expected exit code for
     11# make.  If not specified, it's assumed that the make program should succeed
     12# (exit with 0).
    1013
    11 open(MAKEFILE,"> $makefile");
     14run_make_test('Your test makefile goes here',
     15              'Arguments to pass to make go here',
     16              'Expected output from the invocation goes here');
    1217
    13 # The Contents of the MAKEFILE ...
     18# There are various special tokens, options, etc.  See the full documentation
     19# in run_make_tests.pl.
    1420
    15 print MAKEFILE " <FILL IN THE CONTENTS OF THE MAKEFILE HERE>  \n";
    16 
    17 # END of Contents of MAKEFILE
    18 
    19 close(MAKEFILE);
    20 
    21 
    22 # Run make.  You may specify a makefile, but if you don't want to, just
    23 # insert "" where $make_filename is now.  You may also specify specific
    24 # options to run make with, but you also don't have to. (Insert "" where it
    25 # says <FILL IN OPTIONS HERE>), The last field in this subroutine call
    26 # is the code which is returned from make.  If you think that make should
    27 # execute with no errors, you may OPTIONALLY put 0; Otherwise put the
    28 # error code that you expect back from make for this test.
    29 
    30 # Every time you run make, you just need to say &get_logfile and that
    31 # subroutine will get a new logfile name for you in incrementing order
    32 # according to how many times you call it within ONE test.  It is
    33 # reset to 0 at the beginning of every new test script.
    34 
    35 &run_make_with_options($makefile,
    36                        "<FILL IN OPTIONS HERE>",
    37                        &get_logfile,
    38                        0);
    39 
    40 
    41 # THE REST OF THIS FILE DEPENDS HIGHLY ON WHAT KIND OF TEST YOU ARE
    42 # CREATING, SO IT WILL VARY.  BASICALLY, YOU MAY INSERT ANYTHING YOU
    43 # WISH AT THIS POINT TO SEE IF THE TEST WORKED OK.  IF THERE ARE
    44 # ADDITIONAL TESTS BESIDES &compare_output, AND IT FAILES, YOU
    45 # MUST *** SET $test_passed = 0 !!! ***
    46 
    47 # Create the answer to what should be produced by this Makefile
    48 $answer = "<INSERT ANSWER HERE>";
    49 
    50 # COMPARE RESULTS
    51 
    52 # In this call to compare output, you should use the call &get_logfile(1)
    53 # to send the name of the last logfile created.  You may also use
    54 # the special call &get_logfile(1) which returns the same as &get_logfile(1).
    55 
    56 &compare_output($answer,&get_logfile(1));
    57 
    58 # If you wish to &error ("abort
    59 ") if the compare fails, then add a "|| &error ("abort
    60 ")" to the
    61 # end of the previous line.
    6221
    6322# This tells the test driver that the perl test script executed properly.
  • branches/GNU/src/gmake/tests/test_driver.pl

    r53 r280  
    1 #!/usr/local/bin/perl
     1#!/usr/bin/perl
    22# -*-perl-*-
    33
     
    1212# this routine controls the whole mess; each test suite sets up a few
    1313# variables and then calls &toplevel, which does all the real work.
     14
     15# $Id: test_driver.pl,v 1.14 2005/02/28 07:48:23 psmith Exp $
     16
     17
     18# The number of test categories we've run
     19$categories_run = 0;
     20# The number of test categroies that have passed
     21$categories_passed = 0;
     22# The total number of individual tests that have been run
     23$total_tests_run = 0;
     24# The total number of individual tests that have passed
     25$total_tests_passed = 0;
     26# The number of tests in this category that have been run
     27$tests_run = 0;
     28# The number of tests in this category that have passed
     29$tests_passed = 0;
     30
     31
     32# Yeesh.  This whole test environment is such a hack!
     33$test_passed = 1;
    1434
    1535sub toplevel
     
    151171  $| = 1;
    152172
    153   if ($num_failed)
    154   {
    155     print "\n$num_failed Test";
    156     print "s" unless $num_failed == 1;
     173  $categories_failed = $categories_run - $categories_passed;
     174  $total_tests_failed = $total_tests_run - $total_tests_passed;
     175
     176  if ($total_tests_failed)
     177  {
     178    print "\n$total_tests_failed Test";
     179    print "s" unless $total_tests_failed == 1;
     180    print " in $categories_failed Categor";
     181    print ($categories_failed == 1 ? "y" : "ies");
    157182    print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n";
    158183    return 0;
     
    160185  else
    161186  {
    162     print "\n$counter Test";
    163     print "s" unless $counter == 1;
     187    print "\n$total_tests_passed Test";
     188    print "s" unless $total_tests_passed == 1;
     189    print " in $categories_passed Categor";
     190    print ($categories_passed == 1 ? "y" : "ies");
    164191    print " Complete ... No Failures :-)\n\n";
    165192    return 1;
     
    349376sub run_each_test
    350377{
    351   $counter = 0;
     378  $categories_run = 0;
    352379
    353380  foreach $testname (sort @TESTS)
    354381  {
    355     $counter++;
    356     $test_passed = 1;       # reset by test on failure
     382    ++$categories_run;
     383    $suite_passed = 1;       # reset by test on failure
    357384    $num_of_logfiles = 0;
    358385    $num_of_tmpfiles = 0;
    359386    $description = "";
    360387    $details = "";
     388    $old_makefile = undef;
    361389    $testname =~ s/^$scriptpath$pathsep//;
    362390    $perl_testname = "$scriptpath$pathsep$testname";
     
    391419
    392420    # Run the actual test!
    393     #
     421    $tests_run = 0;
     422    $tests_passed = 0;
    394423    $code = do $perl_testname;
     424
     425    $total_tests_run += $tests_run;
     426    $total_tests_passed += $tests_passed;
     427
     428    # How did it go?
    395429    if (!defined($code))
    396430    {
    397       $test_passed = 0;
     431      $suite_passed = 0;
    398432      if (length ($@))
    399433      {
     
    406440    }
    407441    elsif ($code == -1) {
    408       $test_passed = 0;
     442      $suite_passed = 0;
    409443    }
    410444    elsif ($code != 1 && $code != -1) {
    411       $test_passed = 0;
     445      $suite_passed = 0;
    412446      warn "\n*** Test returned $code\n";
    413447    }
    414448
    415     if ($test_passed) {
    416       $status = "ok";
     449    if ($suite_passed) {
     450      ++$categories_passed;
     451      $status = "ok     ($tests_passed passed)";
    417452      for ($i = $num_of_tmpfiles; $i; $i--)
    418453      {
    419         &delete ($tmp_filename . &num_suffix ($i) );
     454        &rmfiles ($tmp_filename . &num_suffix ($i) );
    420455      }
    421456
    422457      for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--)
    423458      {
    424         &delete ($log_filename . &num_suffix ($i) );
    425         &delete ($base_filename . &num_suffix ($i) );
     459        &rmfiles ($log_filename . &num_suffix ($i) );
     460        &rmfiles ($base_filename . &num_suffix ($i) );
    426461      }
    427462    }
    428463    elsif ($code > 0) {
    429       $status = "FAILED";
    430       $num_failed++;
     464      $status = "FAILED ($tests_passed/$tests_run passed)";
    431465    }
    432466    elsif ($code < 0) {
    433467      $status = "N/A";
    434       --$counter;
     468      --$categories_run;
    435469    }
    436470
     
    467501# are sent to it.
    468502
    469 sub delete
     503sub rmfiles
    470504{
    471505  local(@files) = @_;
     
    578612{
    579613  local($answer,$logfile) = @_;
    580   local($slurp);
    581 
    582   if ($debug)
    583   {
    584     print "Comparing Output ........ ";
    585   }
     614  local($slurp, $answer_matched) = ('', 0);
     615
     616  print "Comparing Output ........ " if $debug;
    586617
    587618  $slurp = &read_file_into_string ($logfile);
     
    592623  $slurp =~ s/^.*Clock skew detected.*\n//gm;
    593624
    594   if ($slurp eq $answer)
    595   {
    596     if ($debug)
    597     {
    598       print "ok\n";
    599     }
     625  ++$tests_run;
     626
     627  if ($slurp eq $answer) {
     628    $answer_matched = 1;
     629  } else {
     630    # See if it is a slash or CRLF problem
     631    local ($answer_mod) = $answer;
     632
     633    $answer_mod =~ tr,\\,/,;
     634    $answer_mod =~ s,\r\n,\n,gs;
     635
     636    $slurp =~ tr,\\,/,;
     637    $slurp =~ s,\r\n,\n,gs;
     638
     639    $answer_matched = ($slurp eq $answer_mod);
     640  }
     641
     642  if ($answer_matched && $test_passed)
     643  {
     644    print "ok\n" if $debug;
     645    ++$tests_passed;
    600646    return 1;
    601647  }
    602   else
    603   {
    604     if ($debug)
    605     {
    606       print "DIFFERENT OUTPUT\n";
    607     }
    608     $test_passed = 0;
     648
     649  if (! $answer_matched) {
     650    print "DIFFERENT OUTPUT\n" if $debug;
     651
    609652    &create_file (&get_basefile, $answer);
    610653
    611     if ($debug)
    612     {
    613       print "\nCreating Difference File ...\n";
    614     }
     654    print "\nCreating Difference File ...\n" if $debug;
     655
    615656    # Create the difference file
     657
    616658    local($command) = "diff -c " . &get_basefile . " " . $logfile;
    617659    &run_command_with_output(&get_difffile,$command);
    618 
    619     return 0;
    620   }
     660  }
     661
     662  $suite_passed = 0;
     663  return 0;
    621664}
    622665
     
    702745  local ($code);
    703746
    704   if ($debug)
    705   {
    706     print "\nrun_command: @_\n";
    707     $code = system @_;
    708     print "run_command: \"@_\" returned $code.\n";
    709     return $code;
    710   }
    711 
    712   return system @_;
     747  print "\nrun_command: @_\n" if $debug;
     748  $code = system @_;
     749  print "run_command: \"@_\" returned $code.\n" if $debug;
     750
     751  return $code;
    713752}
    714753
     
    726765  $code = system @_;
    727766  &detach_default_output;
    728   if ($debug)
    729   {
    730     print "run_command_with_output: \"@_\" returned $code.\n";
    731   }
     767
     768  print "run_command_with_output: '@_' returned $code.\n" if $debug;
    732769
    733770  return $code;
Note: See TracChangeset for help on using the changeset viewer.