patch, new test features/exec.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

patch, new test features/exec.

Gnu - Make - Bugs mailing list
Good morning.

This patch adds a new test features/exec.
features/exec tests that make can execute binaries as well as scripts with
various shabangs and without a shebang and also with various values of SHELL=.
The test demonstrates that the current (4.2.92) implementation fails to execute
a shell program which has no shebang on systems where posix_spawn returns 0 and
then fails (bug 57022).  The test also has 13 other tests which pass.
Tested on sunos, linux and aix.

regards, Dmitry


diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl
index b36de69..51bf6fe 100644
--- a/tests/run_make_tests.pl
+++ b/tests/run_make_tests.pl
@@ -263,12 +263,13 @@ sub run_make_test
       $answer = subst_make_string($answer);
   }

-  run_make_with_options($makefile, $options, &get_logfile(0),
+  my $result = run_make_with_options($makefile, $options, &get_logfile(0),
                         $err_code, $timeout, @call);
   &compare_output($answer, &get_logfile(1));

   $old_makefile = $makefile;
   $makefile = undef;
+  return $result;
 }

 sub add_options {
diff --git a/tests/scripts/features/exec b/tests/scripts/features/exec
new file mode 100644
index 0000000..7c2ac0e
--- /dev/null
+++ b/tests/scripts/features/exec
@@ -0,0 +1,64 @@
+use warnings;
+use Config;
+
+my $description = "Test that make can execute binaries as well as scripts with"
+                 ." various shabangs and without a shebang";
+my $details = "The various shells that this test uses are the default "
+             ."/bin/sh, $origENV{SHELL} and the perl interpreter that is "
+             ." executing this test program. The shells are used for the value"
+             ." of SHELL inside the test makefile and also as a shebang in the"
+             ." executed script. There is also a test which executes a script"
+             ." that has no shebang.";
+
+my $usersh = $origENV{SHELL};
+my $perl = $Config{perlpath};
+my $stem = 'work/features/exec.cmd';
+my $cmd = "$stem";
+my $answer = 'hello, world';
+
+
+# tests [0-11]
+# Have a makefile with various SHELL= exec a shell program with varios
+# shebangs or without a shebang at all.
+my @shebangs = ('', '#!/bin/sh', "#!$usersh", "#!$perl");
+my @shells = ('', 'SHELL=/bin/sh', "SHELL=$usersh");
+my $k = 0;
+for my $shebang (@shebangs) {
+    for my $shell (@shells) {
+        $cmd = "$stem.$k" if ($k);
+        ++$k;
+        unlink $cmd;
+        open(CMD,"> $cmd");
+        print CMD "$shebang\n";
+        print CMD "printf \"$answer\\n\"\n";
+        close(CMD);
+        chmod 0700, $cmd;
+
+        my $result = &run_make_test(qq!
+$shell
+all:; \@$cmd
+                         !, '', "$answer");
+        next if $keep;
+        next unless $result;
+        unlink $cmd;
+    }
+}
+
+# tests [12-14]
+# Exec a binary from a makefile that has SHELL=.
+for my $shell (@shells) {
+    &run_make_test(qq!
+$shell
+all:; \@$perl -e 'printf "$answer\\n"';
+                     !, '', "$answer");
+}
+
+# test 15
+# Use perl as a shell.
+&run_make_test(qq!
+SHELL=$perl
+.SHELLFLAGS=-e
+all:; \@printf "$answer\\n";
+                 !, '', "$answer");
+
+1;

_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make