diff options
Diffstat (limited to 'tests/run_make_tests.pl')
-rwxr-xr-x | tests/run_make_tests.pl | 132 |
1 files changed, 83 insertions, 49 deletions
diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl index 4389d43..8452c6b 100755 --- a/tests/run_make_tests.pl +++ b/tests/run_make_tests.pl @@ -48,66 +48,100 @@ sub valid_option return 0; } -sub run_make_with_options + +# This is an "all-in-one" function. Arguments are as follows: +# +# [0] (string): The makefile to be tested. +# [1] (string): Arguments to pass to make. +# [2] (string): Answer we should get back. +# [3] (integer): Exit code we expect. A missing code means 0 (success) + +sub run_make_test { - local ($filename,$options,$logname,$expected_code) = @_; - local($code); - local($command) = $make_path; + local ($makestring, $options, $answer, $err_code) = @_; - $expected_code = 0 unless defined($expected_code); + if (! defined($makefile)) { + $makefile = &get_tmpfile(); + } - if ($filename) - { - $command .= " -f $filename"; - } + # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to + # make in both $makestring and $answer. - if ($options) - { - $command .= " $options"; - } + $makestring =~ s/#MAKEFILE#/$makefile/g; + $makestring =~ s/#MAKE#/$make_name/g; - if ($valgrind) { - print VALGRIND "\n\nExecuting: $command\n"; - } + $answer =~ s/#MAKEFILE#/$makefile/g; + $answer =~ s/#MAKE#/$make_name/g; - $code = &run_command_with_output($logname,$command); + open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n"; + print MAKEFILE $makestring, "\n"; + close(MAKEFILE) || die "Failed to write $makefile: $!\n"; - # Check to see if we have Purify errors. If so, keep the logfile. - # For this to work you need to build with the Purify flag -exit-status=yes + &run_make_with_options($makefile, $options, &get_logfile(0), $err_code); + &compare_output($answer, &get_logfile(1)); - if ($pure_log && -f $pure_log) { - if ($code & 0x7000) { - $code &= ~0x7000; + $makefile = undef; +} - # If we have a purify log, save it - $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : ""); - print("Renaming purify log file to $tn\n") if $debug; - rename($pure_log, "$tn") - || die "Can't rename $log to $tn: $!\n"; - ++$purify_errors; - } - else { - unlink($pure_log); - } - } +# The old-fashioned way... +sub run_make_with_options { + local ($filename,$options,$logname,$expected_code) = @_; + local($code); + local($command) = $make_path; - if ($code != $expected_code) - { - print "Error running $make_path ($code): $command\n"; - $test_passed = 0; - # If it's a SIGINT, stop here - if ($code & 127) { - print STDERR "\nCaught signal ".($code & 127)."!\n"; - exit($code); - } - return 0; - } + $expected_code = 0 unless defined($expected_code); - if ($profile & $vos) - { - system "add_profile $make_path"; - } -1; + # Reset to reflect this one test. + $test_passed = 1; + + if ($filename) { + $command .= " -f $filename"; + } + + if ($options) { + $command .= " $options"; + } + + if ($valgrind) { + print VALGRIND "\n\nExecuting: $command\n"; + } + + $code = &run_command_with_output($logname,$command); + + # Check to see if we have Purify errors. If so, keep the logfile. + # For this to work you need to build with the Purify flag -exit-status=yes + + if ($pure_log && -f $pure_log) { + if ($code & 0x7000) { + $code &= ~0x7000; + + # If we have a purify log, save it + $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : ""); + print("Renaming purify log file to $tn\n") if $debug; + rename($pure_log, "$tn") + || die "Can't rename $log to $tn: $!\n"; + ++$purify_errors; + } else { + unlink($pure_log); + } + } + + if ($code != $expected_code) { + print "Error running $make_path (expected $expected_code; got $code): $command\n"; + $test_passed = 0; + # If it's a SIGINT, stop here + if ($code & 127) { + print STDERR "\nCaught signal ".($code & 127)."!\n"; + exit($code); + } + return 0; + } + + if ($profile & $vos) { + system "add_profile $make_path"; + } + + 1; } sub print_usage |