File: watchdog.t

package info (click to toggle)
libobject-remote-perl 0.004000-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 488 kB
  • ctags: 248
  • sloc: perl: 2,408; makefile: 7
file content (45 lines) | stat: -rw-r--r-- 695 bytes parent folder | download | duplicates (2)
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
43
44
45
use strictures 1;
use Test::More;

$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1;

use Object::Remote::Connection;
use Object::Remote::FromData;

$SIG{ALRM} = sub {  fail("Watchdog killed remote process in time"); die "test failed" };

my $conn = Object::Remote->connect("-", watchdog_timeout => 1);

my $remote = HangClass->new::on($conn);

isa_ok($remote, 'Object::Remote::Proxy');
is($remote->alive, 1, "Hanging test object is running");

alarm(3);

eval { $remote->hang };

like($@, qr/^Object::Remote connection lost: (?:eof|.*Broken pipe)/, "Correct error message");

done_testing;

__DATA__

package HangClass;

use Moo;

sub alive {
  return 1;
}

sub hang {
  while(1) {
    sleep(1);
  }
}