summaryrefslogtreecommitdiff
path: root/tests/run_make_tests.pl
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2004-05-16 19:16:52 +0000
committerPaul Smith <psmith@gnu.org>2004-05-16 19:16:52 +0000
commit08c8105c5468ff743d2f2ff2fdf3b77a6313b53e (patch)
tree51954f0469a6d70c1b58fd30a5955aa5e4b65c86 /tests/run_make_tests.pl
parente334942e573ea8a4416eca0afafcaf45c3bba06f (diff)
downloadgunmake-08c8105c5468ff743d2f2ff2fdf3b77a6313b53e.tar.gz
Various enhancements
- OS/2 Patches - OpenVMS updates - Sanitize the handling of -include/sinclude with and without -k - Fix the setting of $< for order-only rules.
Diffstat (limited to 'tests/run_make_tests.pl')
-rwxr-xr-xtests/run_make_tests.pl132
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