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