From: Jarkko Hietaniemi Date: Mon, 30 Jun 2003 07:20:58 +0000 (+0000) Subject: $0 test tweaks from Andreas. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ecce83c2318389c6dd5770c975354bb2411bd50f;p=p5sagit%2Fp5-mst-13.2.git $0 test tweaks from Andreas. p4raw-id: //depot/perl@19887 --- diff --git a/ext/threads/t/join.t b/ext/threads/t/join.t index 3818e49..f8b758e 100644 --- a/ext/threads/t/join.t +++ b/ext/threads/t/join.t @@ -103,17 +103,17 @@ if ($^O eq 'linux') { # We parse ps output so this is OS-dependent. if (open PS, "ps -f |") { # Note: must work in (all) Linux(es). my ($sawpid, $sawexe); while () { - 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 { diff --git a/t/op/magic.t b/t/op/magic.t index f48422b..611a01b 100755 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -36,7 +36,7 @@ sub skip { return 1; } -print "1..52\n"; +print "1..53\n"; $Is_MSWin32 = $^O eq 'MSWin32'; $Is_NetWare = $^O eq 'NetWare'; @@ -286,10 +286,23 @@ else { open CMDLINE, "/proc/$$/cmdline") { chomp(my $line = scalar ); 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; } }