File: failed_fork.t

package info (click to toggle)
libtest-fork-perl 0.02-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 84 kB
  • sloc: perl: 135; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl -w

use Test::Builder::Tester tests => 2;
use Test::More;


# Doesn't actually matter what we set errno to, so long as we know
# what the resulting string will be.
my $errno = 1;
my $errno_string;
{
    local $! = $errno;
    $errno_string = $!;
}


# This must come before we use Test::Fork.
BEGIN {
    *CORE::GLOBAL::fork = sub () {
        $! = $errno;
        return undef;
    };
}

use Test::Fork;

is fork(), undef, 'fork deliberately broken';

test_out("not ok 1 - fork() failed: $errno_string");
test_fail(+3);
fork_ok(1, sub {
    fail();
});
test_test("fork_ok() fails when fork() doesn't work");