Commit | Line | Data |
8d063cd8 |
1 | #!./perl |
2 | |
9247405f |
3 | BEGIN: { |
4 | chdir 't' if -d 't'; |
5 | @INC = ('../lib'); |
972e7321 |
6 | require './test.pl'; |
9247405f |
7 | } |
8 | |
9 | # supress VMS whinging about bad execs. |
10 | use vmsish qw(hushed); |
11 | |
8d063cd8 |
12 | $| = 1; # flush stdout |
68dc0745 |
13 | |
9429f27a |
14 | $ENV{LC_ALL} = 'C'; # Forge English error messages. |
15 | $ENV{LANGUAGE} = 'C'; # Ditto in GNU. |
16 | |
972e7321 |
17 | plan(tests => 14); |
18 | |
19 | my $Perl = which_perl(); |
68dc0745 |
20 | |
9247405f |
21 | my $exit; |
22 | SKIP: { |
23 | skip("bug/feature of pdksh", 2) if $^O eq 'os2'; |
24 | |
972e7321 |
25 | $exit = system qq{$Perl -le "print q{ok 1 - interpreted system(EXPR)"}}; |
9247405f |
26 | next_test(); |
27 | is( $exit, 0, ' exited 0' ); |
95e8664e |
28 | } |
29 | |
972e7321 |
30 | $exit = system qq{$Perl -le "print q{ok 3 - split & direct call system(EXPR)"}}; |
9247405f |
31 | next_test(); |
32 | is( $exit, 0, ' exited 0' ); |
33 | |
34 | # On VMS you need the quotes around the program or it won't work. |
35 | # On Unix its the opposite. |
36 | my $quote = $^O eq 'VMS' ? '"' : ''; |
972e7321 |
37 | $exit = system $Perl, '-le', |
9247405f |
38 | "${quote}print q{ok 5 - system(PROG, LIST)}${quote}"; |
39 | next_test(); |
40 | is( $exit, 0, ' exited 0' ); |
41 | |
8d063cd8 |
42 | |
972e7321 |
43 | is( system(qq{$Perl -e "exit 0"}), 0, 'Explicit exit of 0' ); |
9247405f |
44 | |
45 | my $exit_one = $^O eq 'VMS' ? 4 << 8 : 1 << 8; |
972e7321 |
46 | is( system(qq{$Perl "-I../lib" -e "use vmsish qw(hushed); exit 1"}), $exit_one, |
9247405f |
47 | 'Explicit exit of 1' ); |
48 | |
49 | |
50 | $rc = system "lskdfj"; |
51 | unless( ok($rc == 255 << 8 or $rc == -1 or $rc == 256) ) { |
52 | print "# \$rc == $rc\n"; |
ec40c0cd |
53 | } |
8d063cd8 |
54 | |
9247405f |
55 | unless ( ok( $! == 2 or $! =~ /\bno\b.*\bfile/i or |
56 | $! == 13 or $! =~ /permission denied/i or |
57 | $! == 22 or $! =~ /invalid argument/ ) ) { |
58 | printf "# \$! eq %d, '%s'\n", $!, $!; |
59 | } |
60 | |
972e7321 |
61 | |
62 | is( `$Perl -le "print 'ok'"`, "ok\n", 'basic ``' ); |
63 | is( <<`END`, "ok\n", '<<`HEREDOC`' ); |
64 | $Perl -le "print 'ok'" |
65 | END |
66 | |
67 | |
9247405f |
68 | TODO: { |
69 | if( $^O =~ /Win32/ ) { |
70 | print "not ok 11 - exec failure doesn't terminate process # TODO Win32 exec failure waits for user input\n"; |
71 | last TODO; |
72 | } |
378cc40b |
73 | |
9247405f |
74 | ok( !exec("lskdjfalksdjfdjfkls"), |
75 | "exec failure doesn't terminate process"); |
0994c4d0 |
76 | } |
378cc40b |
77 | |
972e7321 |
78 | my $test = curr_test(); |
79 | exec $Perl, '-le', qq{${quote}print 'ok $test - exec PROG, LIST'${quote}}; |
9247405f |
80 | fail("This should never be reached if the exec() worked"); |