| 1 | #!./perl |
| 2 | |
| 3 | BEGIN { |
| 4 | $| = 1; |
| 5 | chdir 't' if -d 't'; |
| 6 | @INC = '../lib'; |
| 7 | $ENV{PATH} = '/bin' if ${^TAINT}; |
| 8 | $SIG{__WARN__} = sub { die "Dying on warning: ", @_ }; |
| 9 | require './test.pl'; |
| 10 | } |
| 11 | |
| 12 | use warnings; |
| 13 | use Config; |
| 14 | |
| 15 | plan (tests => 87); |
| 16 | |
| 17 | $Is_MSWin32 = $^O eq 'MSWin32'; |
| 18 | $Is_NetWare = $^O eq 'NetWare'; |
| 19 | $Is_VMS = $^O eq 'VMS'; |
| 20 | $Is_Dos = $^O eq 'dos'; |
| 21 | $Is_os2 = $^O eq 'os2'; |
| 22 | $Is_Cygwin = $^O eq 'cygwin'; |
| 23 | $Is_MPE = $^O eq 'mpeix'; |
| 24 | $Is_BeOS = $^O eq 'beos'; |
| 25 | |
| 26 | $PERL = $ENV{PERL} |
| 27 | || ($Is_NetWare ? 'perl' : |
| 28 | $Is_VMS ? $^X : |
| 29 | $Is_MSWin32 ? '.\perl' : |
| 30 | './perl'); |
| 31 | |
| 32 | END { |
| 33 | # On VMS, environment variable changes are peristent after perl exits |
| 34 | delete $ENV{'FOO'} if $Is_VMS; |
| 35 | } |
| 36 | |
| 37 | eval '$ENV{"FOO"} = "hi there";'; # check that ENV is inited inside eval |
| 38 | # cmd.exe will echo 'variable=value' but 4nt will echo just the value |
| 39 | # -- Nikola Knezevic |
| 40 | if ($Is_MSWin32) { like `set FOO`, qr/^(?:FOO=)?hi there$/; } |
| 41 | elsif ($Is_VMS) { is `write sys\$output f\$trnlnm("FOO")`, "hi there\n"; } |
| 42 | else { is `echo \$FOO`, "hi there\n"; } |
| 43 | |
| 44 | unlink_all 'ajslkdfpqjsjfk'; |
| 45 | $! = 0; |
| 46 | open(FOO,'ajslkdfpqjsjfk'); |
| 47 | isnt($!, 0); |
| 48 | close FOO; # just mention it, squelch used-only-once |
| 49 | |
| 50 | SKIP: { |
| 51 | skip('SIGINT not safe on this platform', 5) |
| 52 | if $Is_MSWin32 || $Is_NetWare || $Is_Dos || $Is_MPE; |
| 53 | # the next tests are done in a subprocess because sh spits out a |
| 54 | # newline onto stderr when a child process kills itself with SIGINT. |
| 55 | # We use a pipe rather than system() because the VMS command buffer |
| 56 | # would overflow with a command that long. |
| 57 | |
| 58 | open( CMDPIPE, "| $PERL"); |
| 59 | |
| 60 | print CMDPIPE <<'END'; |
| 61 | |
| 62 | $| = 1; # command buffering |
| 63 | |
| 64 | $SIG{"INT"} = "ok3"; kill "INT",$$; sleep 1; |
| 65 | $SIG{"INT"} = "IGNORE"; kill "INT",$$; sleep 1; print "ok 4\n"; |
| 66 | $SIG{"INT"} = "DEFAULT"; kill "INT",$$; sleep 1; print "not ok 4\n"; |
| 67 | |
| 68 | sub ok3 { |
| 69 | if (($x = pop(@_)) eq "INT") { |
| 70 | print "ok 3\n"; |
| 71 | } |
| 72 | else { |
| 73 | print "not ok 3 ($x @_)\n"; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | END |
| 78 | |
| 79 | close CMDPIPE; |
| 80 | |
| 81 | open( CMDPIPE, "| $PERL"); |
| 82 | print CMDPIPE <<'END'; |
| 83 | |
| 84 | { package X; |
| 85 | sub DESTROY { |
| 86 | kill "INT",$$; |
| 87 | } |
| 88 | } |
| 89 | sub x { |
| 90 | my $x=bless [], 'X'; |
| 91 | return sub { $x }; |
| 92 | } |
| 93 | $| = 1; # command buffering |
| 94 | $SIG{"INT"} = "ok5"; |
| 95 | { |
| 96 | local $SIG{"INT"}=x(); |
| 97 | print ""; # Needed to expose failure in 5.8.0 (why?) |
| 98 | } |
| 99 | sleep 1; |
| 100 | delete $SIG{"INT"}; |
| 101 | kill "INT",$$; sleep 1; |
| 102 | sub ok5 { |
| 103 | print "ok 5\n"; |
| 104 | } |
| 105 | END |
| 106 | close CMDPIPE; |
| 107 | $? >>= 8 if $^O eq 'VMS'; # POSIX status hiding in 2nd byte |
| 108 | my $todo = ($^O eq 'os2' ? ' # TODO: EMX v0.9d_fix4 bug: wrong nibble? ' : ''); |
| 109 | print $? & 0xFF ? "ok 6$todo\n" : "not ok 6$todo\n"; |
| 110 | |
| 111 | open(CMDPIPE, "| $PERL"); |
| 112 | print CMDPIPE <<'END'; |
| 113 | |
| 114 | sub PVBM () { 'foo' } |
| 115 | index 'foo', PVBM; |
| 116 | my $pvbm = PVBM; |
| 117 | |
| 118 | sub foo { exit 0 } |
| 119 | |
| 120 | $SIG{"INT"} = $pvbm; |
| 121 | kill "INT", $$; sleep 1; |
| 122 | END |
| 123 | close CMDPIPE; |
| 124 | $? >>= 8 if $^O eq 'VMS'; |
| 125 | print $? ? "not ok 7\n" : "ok 7\n"; |
| 126 | |
| 127 | curr_test(curr_test() + 5); |
| 128 | } |
| 129 | |
| 130 | # can we slice ENV? |
| 131 | @val1 = @ENV{keys(%ENV)}; |
| 132 | @val2 = values(%ENV); |
| 133 | is join(':',@val1), join(':',@val2); |
| 134 | cmp_ok @val1, '>', 1; |
| 135 | |
| 136 | # regex vars |
| 137 | 'foobarbaz' =~ /b(a)r/; |
| 138 | is $`, 'foo'; |
| 139 | is $&, 'bar'; |
| 140 | is $', 'baz'; |
| 141 | is $+, 'a'; |
| 142 | |
| 143 | # $" |
| 144 | @a = qw(foo bar baz); |
| 145 | is "@a", "foo bar baz"; |
| 146 | { |
| 147 | local $" = ','; |
| 148 | is "@a", "foo,bar,baz"; |
| 149 | } |
| 150 | |
| 151 | # $; |
| 152 | %h = (); |
| 153 | $h{'foo', 'bar'} = 1; |
| 154 | is((keys %h)[0], "foo\034bar"); |
| 155 | { |
| 156 | local $; = 'x'; |
| 157 | %h = (); |
| 158 | $h{'foo', 'bar'} = 1; |
| 159 | is((keys %h)[0], 'fooxbar'); |
| 160 | } |
| 161 | |
| 162 | # $?, $@, $$ |
| 163 | system qq[$PERL "-I../lib" -e "use vmsish qw(hushed); exit(0)"]; |
| 164 | is $?, 0; |
| 165 | system qq[$PERL "-I../lib" -e "use vmsish qw(hushed); exit(1)"]; |
| 166 | isnt $?, 0; |
| 167 | |
| 168 | eval { die "foo\n" }; |
| 169 | is $@, "foo\n"; |
| 170 | |
| 171 | cmp_ok($$, '>', 0); |
| 172 | eval { $$++ }; |
| 173 | like ($@, qr/^Modification of a read-only value attempted/); |
| 174 | |
| 175 | # $^X and $0 |
| 176 | { |
| 177 | if ($^O eq 'qnx') { |
| 178 | chomp($wd = `/usr/bin/fullpath -t`); |
| 179 | } |
| 180 | elsif($Is_Cygwin || $Config{'d_procselfexe'}) { |
| 181 | # Cygwin turns the symlink into the real file |
| 182 | chomp($wd = `pwd`); |
| 183 | $wd =~ s#/t$##; |
| 184 | $wd =~ /(.*)/; $wd = $1; # untaint |
| 185 | if ($Is_Cygwin) { |
| 186 | $wd = Cygwin::win_to_posix_path(Cygwin::posix_to_win_path($wd, 1)); |
| 187 | } |
| 188 | } |
| 189 | elsif($Is_os2) { |
| 190 | $wd = Cwd::sys_cwd(); |
| 191 | } |
| 192 | else { |
| 193 | $wd = '.'; |
| 194 | } |
| 195 | my $perl = $Is_VMS || $Config{d_procselfexe} ? $^X : "$wd/perl"; |
| 196 | my $headmaybe = ''; |
| 197 | my $middlemaybe = ''; |
| 198 | my $tailmaybe = ''; |
| 199 | $script = "$wd/show-shebang"; |
| 200 | if ($Is_MSWin32) { |
| 201 | chomp($wd = `cd`); |
| 202 | $wd =~ s|\\|/|g; |
| 203 | $perl = "$wd/perl.exe"; |
| 204 | $script = "$wd/show-shebang.bat"; |
| 205 | $headmaybe = <<EOH ; |
| 206 | \@rem =' |
| 207 | \@echo off |
| 208 | $perl -x \%0 |
| 209 | goto endofperl |
| 210 | \@rem '; |
| 211 | EOH |
| 212 | $tailmaybe = <<EOT ; |
| 213 | |
| 214 | __END__ |
| 215 | :endofperl |
| 216 | EOT |
| 217 | } |
| 218 | elsif ($Is_os2) { |
| 219 | $script = "./show-shebang"; |
| 220 | } |
| 221 | elsif ($Is_VMS) { |
| 222 | $script = "[]show-shebang"; |
| 223 | } |
| 224 | elsif ($Is_Cygwin) { |
| 225 | $middlemaybe = <<'EOX' |
| 226 | $^X = Cygwin::win_to_posix_path(Cygwin::posix_to_win_path($^X, 1)); |
| 227 | $0 = Cygwin::win_to_posix_path(Cygwin::posix_to_win_path($0, 1)); |
| 228 | EOX |
| 229 | } |
| 230 | if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') { # no shebang |
| 231 | $headmaybe = <<EOH ; |
| 232 | eval 'exec ./perl -S \$0 \${1+"\$\@"}' |
| 233 | if 0; |
| 234 | EOH |
| 235 | } |
| 236 | $s1 = "\$^X is $perl, \$0 is $script\n"; |
| 237 | ok open(SCRIPT, ">$script") or diag "Can't write to $script: $!"; |
| 238 | ok print(SCRIPT $headmaybe . <<EOB . $middlemaybe . <<'EOF' . $tailmaybe) or diag $!; |
| 239 | #!$perl |
| 240 | EOB |
| 241 | print "\$^X is $^X, \$0 is $0\n"; |
| 242 | EOF |
| 243 | ok close(SCRIPT) or diag $!; |
| 244 | ok chmod(0755, $script) or diag $!; |
| 245 | $_ = $Is_VMS ? `$perl $script` : `$script`; |
| 246 | s/\.exe//i if $Is_Dos or $Is_Cygwin or $Is_os2; |
| 247 | s{./$script}{$script} if $Is_BeOS; # revert BeOS execvp() side-effect |
| 248 | s{is perl}{is $perl}; # for systems where $^X is only a basename |
| 249 | s{\\}{/}g; |
| 250 | if ($Is_MSWin32 || $Is_os2) { |
| 251 | is uc $_, uc $s1; |
| 252 | } else { |
| 253 | is $_, $s1; |
| 254 | } |
| 255 | $_ = `$perl $script`; |
| 256 | s/\.exe//i if $Is_Dos or $Is_os2 or $Is_Cygwin; |
| 257 | s{./$perl}{$perl} if $Is_BeOS; # revert BeOS execvp() side-effect |
| 258 | s{\\}{/}g; |
| 259 | if ($Is_MSWin32 || $Is_os2) { |
| 260 | is uc $_, uc $s1; |
| 261 | } else { |
| 262 | is $_, $s1; |
| 263 | } |
| 264 | ok unlink($script) or diag $!; |
| 265 | # CHECK |
| 266 | # Could this be replaced with: |
| 267 | # unlink_all($script); |
| 268 | } |
| 269 | |
| 270 | # $], $^O, $^T |
| 271 | cmp_ok $], '>=', 5.00319; |
| 272 | ok $^O; |
| 273 | cmp_ok $^T, '>', 850000000; |
| 274 | |
| 275 | # Test change 25062 is working |
| 276 | my $orig_osname = $^O; |
| 277 | { |
| 278 | local $^I = '.bak'; |
| 279 | is $^O, $orig_osname, 'Assigning $^I does not clobber $^O'; |
| 280 | } |
| 281 | $^O = $orig_osname; |
| 282 | |
| 283 | { |
| 284 | #RT #72422 |
| 285 | foreach my $p (0, 1) { |
| 286 | fresh_perl_is(<<"EOP", '2 4 8', undef, "test \$^P = $p"); |
| 287 | \$DB::single = 2; |
| 288 | \$DB::trace = 4; |
| 289 | \$DB::signal = 8; |
| 290 | \$^P = $p; |
| 291 | print "\$DB::single \$DB::trace \$DB::signal"; |
| 292 | EOP |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | # Check that assigning to $0 on Linux sets the process name with both |
| 297 | # argv[0] assignment and by calling prctl() |
| 298 | { |
| 299 | SKIP: { |
| 300 | skip "We don't have prctl() here", 2 unless $Config{d_prctl_set_name}; |
| 301 | |
| 302 | # We don't really need these tests. prctl() is tested in the |
| 303 | # Kernel, but test it anyway for our sanity. If something doesn't |
| 304 | # work (like if the system doesn't have a ps(1) for whatever |
| 305 | # reason) just bail out gracefully. |
| 306 | my $maybe_ps = sub { |
| 307 | my ($cmd) = @_; |
| 308 | local ($?, $!); |
| 309 | |
| 310 | no warnings; |
| 311 | my $res = `$cmd`; |
| 312 | skip "Couldn't shell out to `$cmd', returned code $?", 2 if $?; |
| 313 | return $res; |
| 314 | }; |
| 315 | |
| 316 | my $name = "Good Morning, Dave"; |
| 317 | $0 = $name; |
| 318 | |
| 319 | chomp(my $argv0 = $maybe_ps->("ps h $$")); |
| 320 | chomp(my $prctl = $maybe_ps->("ps hc $$")); |
| 321 | |
| 322 | like($argv0, $name, "Set process name through argv[0] ($argv0)"); |
| 323 | like($prctl, substr($name, 0, 15), "Set process name through prctl() ($prctl)"); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | { |
| 328 | my $ok = 1; |
| 329 | my $warn = ''; |
| 330 | local $SIG{'__WARN__'} = sub { $ok = 0; $warn = join '', @_; $warn =~ s/\n$//; }; |
| 331 | $! = undef; |
| 332 | local $TODO = $Is_VMS ? "'\$!=undef' does throw a warning" : ''; |
| 333 | ok($ok, $warn); |
| 334 | } |
| 335 | |
| 336 | SKIP: { |
| 337 | skip_if_miniperl("miniperl can't rely on loading %Errno", 2); |
| 338 | no warnings 'void'; |
| 339 | |
| 340 | # Make sure Errno hasn't been prematurely autoloaded |
| 341 | |
| 342 | ok !keys %Errno::; |
| 343 | |
| 344 | # Test auto-loading of Errno when %! is used |
| 345 | |
| 346 | ok scalar eval q{ |
| 347 | %!; |
| 348 | scalar %Errno::; |
| 349 | }, $@; |
| 350 | } |
| 351 | |
| 352 | SKIP: { |
| 353 | skip_if_miniperl("miniperl can't rely on loading %Errno", 1); |
| 354 | # Make sure that Errno loading doesn't clobber $! |
| 355 | |
| 356 | undef %Errno::; |
| 357 | delete $INC{"Errno.pm"}; |
| 358 | |
| 359 | open(FOO, "nonesuch"); # Generate ENOENT |
| 360 | my %errs = %{"!"}; # Cause Errno.pm to be loaded at run-time |
| 361 | ok ${"!"}{ENOENT}; |
| 362 | } |
| 363 | |
| 364 | # Check that we don't auto-load packages |
| 365 | SKIP: { |
| 366 | skip "staticly linked; may be preloaded", 4 unless $Config{usedl}; |
| 367 | foreach (['powie::!', 'Errno'], |
| 368 | ['powie::+', 'Tie::Hash::NamedCapture']) { |
| 369 | my ($symbol, $package) = @$_; |
| 370 | foreach my $scalar_first ('', '$$symbol;') { |
| 371 | my $desc = qq{Referencing %{"$symbol"}}; |
| 372 | $desc .= qq{ after mentioning \${"$symbol"}} if $scalar_first; |
| 373 | $desc .= " doesn't load $package"; |
| 374 | |
| 375 | fresh_perl_is(<<"EOP", 0, {}, $desc); |
| 376 | use strict qw(vars subs); |
| 377 | my \$symbol = '$symbol'; |
| 378 | $scalar_first; |
| 379 | 1 if %{\$symbol}; |
| 380 | print scalar %${package}::; |
| 381 | EOP |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | is $^S, 0; |
| 387 | eval { is $^S,1 }; |
| 388 | eval " BEGIN { ok ! defined \$^S } "; |
| 389 | is $^S, 0; |
| 390 | |
| 391 | my $taint = ${^TAINT}; |
| 392 | is ${^TAINT}, $taint; |
| 393 | eval { ${^TAINT} = 1 }; |
| 394 | is ${^TAINT}, $taint; |
| 395 | |
| 396 | # 5.6.1 had a bug: @+ and @- were not properly interpolated |
| 397 | # into double-quoted strings |
| 398 | # 20020414 mjd-perl-patch+@plover.com |
| 399 | "I like pie" =~ /(I) (like) (pie)/; |
| 400 | is "@-", "0 0 2 7"; |
| 401 | is "@+", "10 1 6 10"; |
| 402 | |
| 403 | # Tests for the magic get of $\ |
| 404 | { |
| 405 | my $ok = 0; |
| 406 | # [perl #19330] |
| 407 | { |
| 408 | local $\ = undef; |
| 409 | $\++; $\++; |
| 410 | $ok = $\ eq 2; |
| 411 | } |
| 412 | ok $ok; |
| 413 | $ok = 0; |
| 414 | { |
| 415 | local $\ = "a\0b"; |
| 416 | $ok = "a$\b" eq "aa\0bb"; |
| 417 | } |
| 418 | ok $ok; |
| 419 | } |
| 420 | |
| 421 | # Test for bug [perl #36434] |
| 422 | # Can not do this test on VMS, EPOC, and SYMBIAN according to comments |
| 423 | # in mg.c/Perl_magic_clear_all_env() |
| 424 | SKIP: { |
| 425 | skip('Can\'t make assignment to \%ENV on this system', 3) if $Is_VMS; |
| 426 | |
| 427 | local @ISA; |
| 428 | local %ENV; |
| 429 | # This used to be __PACKAGE__, but that causes recursive |
| 430 | # inheritance, which is detected earlier now and broke |
| 431 | # this test |
| 432 | eval { push @ISA, __FILE__ }; |
| 433 | is $@, '', 'Push a constant on a magic array'; |
| 434 | $@ and print "# $@"; |
| 435 | eval { %ENV = (PATH => __PACKAGE__) }; |
| 436 | is $@, '', 'Assign a constant to a magic hash'; |
| 437 | $@ and print "# $@"; |
| 438 | eval { my %h = qw(A B); %ENV = (PATH => (keys %h)[0]) }; |
| 439 | is $@, '', 'Assign a shared key to a magic hash'; |
| 440 | $@ and print "# $@"; |
| 441 | } |
| 442 | |
| 443 | # Tests for Perl_magic_clearsig |
| 444 | foreach my $sig (qw(__WARN__ INT)) { |
| 445 | $SIG{$sig} = lc $sig; |
| 446 | is $SIG{$sig}, 'main::' . lc $sig, "Can assign to $sig"; |
| 447 | is delete $SIG{$sig}, 'main::' . lc $sig, "Can delete from $sig"; |
| 448 | is $SIG{$sig}, undef, "$sig is now gone"; |
| 449 | is delete $SIG{$sig}, undef, "$sig remains gone"; |
| 450 | } |
| 451 | |
| 452 | # And now one which doesn't exist; |
| 453 | { |
| 454 | no warnings 'signal'; |
| 455 | $SIG{HUNGRY} = 'mmm, pie'; |
| 456 | } |
| 457 | is $SIG{HUNGRY}, 'mmm, pie', 'Can assign to HUNGRY'; |
| 458 | is delete $SIG{HUNGRY}, 'mmm, pie', 'Can delete from HUNGRY'; |
| 459 | is $SIG{HUNGRY}, undef, "HUNGRY is now gone"; |
| 460 | is delete $SIG{HUNGRY}, undef, "HUNGRY remains gone"; |
| 461 | |
| 462 | # Test deleting signals that we never set |
| 463 | foreach my $sig (qw(__DIE__ _BOGUS_HOOK KILL THIRSTY)) { |
| 464 | is $SIG{$sig}, undef, "$sig is not present"; |
| 465 | is delete $SIG{$sig}, undef, "delete of $sig returns undef"; |
| 466 | } |
| 467 | |
| 468 | { |
| 469 | $! = 9999; |
| 470 | is int $!, 9999, q{[perl #72850] Core dump in bleadperl from perl -e '$! = 9999; $a = $!;'}; |
| 471 | |
| 472 | } |
| 473 | |
| 474 | # ^^^^^^^^^ New tests go here ^^^^^^^^^ |
| 475 | |
| 476 | SKIP: { |
| 477 | skip("%ENV manipulations fail or aren't safe on $^O", 4) |
| 478 | if $Is_VMS || $Is_Dos; |
| 479 | |
| 480 | SKIP: { |
| 481 | skip("clearing \%ENV is not safe when running under valgrind") |
| 482 | if $ENV{PERL_VALGRIND}; |
| 483 | |
| 484 | $PATH = $ENV{PATH}; |
| 485 | $PDL = $ENV{PERL_DESTRUCT_LEVEL} || 0; |
| 486 | $ENV{foo} = "bar"; |
| 487 | %ENV = (); |
| 488 | $ENV{PATH} = $PATH; |
| 489 | $ENV{PERL_DESTRUCT_LEVEL} = $PDL || 0; |
| 490 | if ($Is_MSWin32) { |
| 491 | is `set foo 2>NUL`, ""; |
| 492 | } else { |
| 493 | is `echo \$foo`, "\n"; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | $ENV{__NoNeSuCh} = "foo"; |
| 498 | $0 = "bar"; |
| 499 | # cmd.exe will echo 'variable=value' but 4nt will echo just the value |
| 500 | # -- Nikola Knezevic |
| 501 | if ($Is_MSWin32) { |
| 502 | like `set __NoNeSuCh`, qr/^(?:__NoNeSuCh=)?foo$/; |
| 503 | } else { |
| 504 | is `echo \$__NoNeSuCh`, "foo\n"; |
| 505 | } |
| 506 | SKIP: { |
| 507 | skip("\$0 check only on Linux and FreeBSD", 2) |
| 508 | unless $^O =~ /^(linux|freebsd)$/ |
| 509 | && open CMDLINE, "/proc/$$/cmdline"; |
| 510 | |
| 511 | chomp(my $line = scalar <CMDLINE>); |
| 512 | my $me = (split /\0/, $line)[0]; |
| 513 | is $me, $0, 'altering $0 is effective (testing with /proc/)'; |
| 514 | close CMDLINE; |
| 515 | # perlbug #22811 |
| 516 | my $mydollarzero = sub { |
| 517 | my($arg) = shift; |
| 518 | $0 = $arg if defined $arg; |
| 519 | # In FreeBSD the ps -o command= will cause |
| 520 | # an empty header line, grab only the last line. |
| 521 | my $ps = (`ps -o command= -p $$`)[-1]; |
| 522 | return if $?; |
| 523 | chomp $ps; |
| 524 | printf "# 0[%s]ps[%s]\n", $0, $ps; |
| 525 | $ps; |
| 526 | }; |
| 527 | my $ps = $mydollarzero->("x"); |
| 528 | ok(!$ps # we allow that something goes wrong with the ps command |
| 529 | # In Linux 2.4 we would get an exact match ($ps eq 'x') but |
| 530 | # in Linux 2.2 there seems to be something funny going on: |
| 531 | # it seems as if the original length of the argv[] would |
| 532 | # be stored in the proc struct and then used by ps(1), |
| 533 | # no matter what characters we use to pad the argv[]. |
| 534 | # (And if we use \0:s, they are shown as spaces.) Sigh. |
| 535 | || $ps =~ /^x\s*$/ |
| 536 | # FreeBSD cannot get rid of both the leading "perl :" |
| 537 | # and the trailing " (perl)": some FreeBSD versions |
| 538 | # can get rid of the first one. |
| 539 | || ($^O eq 'freebsd' && $ps =~ m/^(?:perl: )?x(?: \(perl\))?$/), |
| 540 | 'altering $0 is effective (testing with `ps`)'); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | # test case-insignificance of %ENV (these tests must be enabled only |
| 545 | # when perl is compiled with -DENV_IS_CASELESS) |
| 546 | SKIP: { |
| 547 | skip('no caseless %ENV support', 4) unless $Is_MSWin32 || $Is_NetWare; |
| 548 | |
| 549 | %ENV = (); |
| 550 | $ENV{'Foo'} = 'bar'; |
| 551 | $ENV{'fOo'} = 'baz'; |
| 552 | is scalar(keys(%ENV)), 1; |
| 553 | ok exists $ENV{'FOo'}; |
| 554 | is delete $ENV{'foO'}, 'baz'; |
| 555 | is scalar(keys(%ENV)), 0; |
| 556 | } |
| 557 | |
| 558 | __END__ |
| 559 | |
| 560 | # Put new tests before the various ENV tests, as they blow %ENV away. |