File: Manage.t

package info (click to toggle)
libchild-perl 0.013-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 160 kB
  • sloc: perl: 306; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 614 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl;
use strict;
use warnings;

use Test::More 0.88;
our $CLASS = 'Child';
require_ok( $CLASS );

my @children = map { $CLASS->new(sub { 1 }) } 1 .. 4;
my @get = $CLASS->all_procs;
is( @get, 0, "0 children started" );

my @all;
push @all => $_->start for @children;

@get = $CLASS->all_procs;
is( @get, 4, "4 children" );
is_deeply( \@get, \@all, "Exact list" );

is_deeply(
    [ $CLASS->all_proc_pids ],
    [ map { $_->pid } @all ],
    "pids"
);

is( $_->exit(), undef, "Not waited " . $_->pid ) for @all;
$CLASS->wait_all();
ok( defined($_->exit()), "waited " . $_->pid ) for @all;

done_testing;