Change 19887 by [EMAIL PROTECTED] on 2003/06/30 07:20:58

        $0 test tweaks from Andreas.

Affected files ...

... //depot/perl/ext/threads/t/join.t#10 edit
... //depot/perl/t/op/magic.t#60 edit

Differences ...

==== //depot/perl/ext/threads/t/join.t#10 (text) ====
Index: perl/ext/threads/t/join.t
--- perl/ext/threads/t/join.t#9~19706~  Sat Jun  7 06:07:53 2003
+++ perl/ext/threads/t/join.t   Mon Jun 30 00:20:58 2003
@@ -103,17 +103,17 @@
   if (open PS, "ps -f |") { # Note: must work in (all) Linux(es).
     my ($sawpid, $sawexe);
     while (<PS>) {
-      s/\s+$//; # there seems to be extra whitespace at the end by ps(1)?
-      print "# $_\n";
+      chomp;
+      print "# [$_]\n";
       if (/^\S+\s+$$\s/) {
        $sawpid++;
-       if (/\sfoobar\b/) {
+       if (/\sfoobar$/) {
          $sawexe++;
         }
        last;
       }
     }
-    close PS;
+    close PS or die;
     if ($sawpid) {
       ok($sawpid && $sawexe, 'altering $0 is effective');
     } else {

==== //depot/perl/t/op/magic.t#60 (xtext) ====
Index: perl/t/op/magic.t
--- perl/t/op/magic.t#59~19452~ Thu May  8 11:12:46 2003
+++ perl/t/op/magic.t   Mon Jun 30 00:20:58 2003
@@ -36,7 +36,7 @@
     return 1;
 }
 
-print "1..52\n";
+print "1..53\n";
 
 $Is_MSWin32 = $^O eq 'MSWin32';
 $Is_NetWare = $^O eq 'NetWare';
@@ -286,10 +286,23 @@
            open CMDLINE, "/proc/$$/cmdline") {
            chomp(my $line = scalar <CMDLINE>);
            my $me = (split /\0/, $line)[0];
-           ok($me eq $0, 'altering $0 is effective');
+           ok($me eq $0, 'altering $0 is effective (testing with /proc/)');
            close CMDLINE;
+            # perlbug #22811
+            my $mydollarzero = sub {
+              my($arg) = shift;
+              $0 = $arg if defined $arg;
+              my $ps = `ps -o command= -p $$`;
+              return if $?;
+              chomp $ps;
+              printf "# 0[%s]ps[%s]\n", $0, $ps;
+              $ps;
+            };
+            my $ps = $mydollarzero->("x");
+            ok(!$ps ||   # we allow that something goes wrong with the ps command
+               $ps eq "x", 'altering $0 is effective (testing with `ps`)');
        } else {
-           skip("\$0 check only on Linux and FreeBSD with /proc");
+           skip("\$0 check only on Linux and FreeBSD") for 0,1;
        }
 }
 
End of Patch.

Reply via email to