File: Clean_all_procs.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 (42 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
#!/usr/bin/perl;
use strict;
use warnings;

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

require_ok( $CLASS );

my $spec = $CLASS->new( sub {
    my $self = shift;
    my $in = $self->read();
}, pipe => 1 );

my $child1 = $spec->start;
my $child2 = $spec->start;

sleep 1;

$child1->is_complete;
$child2->is_complete;
ok((grep {$child1 == $_} $CLASS->all_procs), "Found child 1, still active");
ok((grep {$child2 == $_} $CLASS->all_procs), "Found child 2, still active");

$child1->say("anything");

sleep 1;

$child1->is_complete;
$child2->is_complete;
ok(!(grep {$child1 == $_} $CLASS->all_procs), "child 1 not found");
ok((grep {$child2 == $_} $CLASS->all_procs), "Found child 2, still active");

$child2->say("anything");

sleep 1;

Child->wait_all;
ok(!(grep {$child1 == $_} $CLASS->all_procs), "child 1 not found");
ok(!(grep {$child2 == $_} $CLASS->all_procs), "child 2 not found");

done_testing;