#!/usr/bin/perl -w
$|++; $\ =
"\n"
;
ok(1,
'use Proc::PID::File'
);
$pf
= Proc::PID::File->new(
dir
=>
"."
,
name
=>
"test"
,
debug
=>
$ENV
{DEBUG}
);
$pf
->
write
(),
sleep
(30),
exit
()
if
(
shift
||
""
) eq
"--daemon"
;
ok(!
$pf
->alive()
,
"Single instance"
);
ok(! Proc::PID::File->running(
name
=>
"test"
,
dir
=>
"."
)
,
"Simple interface"
);
ok(
$pf
->
read
() == $$,
"Read id"
);
$pf
->remove();
ok(! -f
$pf
->{path},
"Remove tested"
);
exit
(1)
if
-f
$pf
->{path};
system
qq|./test.pl --daemon > /dev/null 2>&1 &|
;
wait
until
-f
$pf
->{path};
ok(1,
"Write test"
);
ok(
$pf
->alive(),
"Second incarnation"
);
$rc
= Proc::PID::File->running(
name
=>
"test"
,
dir
=>
"."
);
ok(
$rc
,
"Simple interface"
);
$rc
= Proc::PID::File->running(
verify
=> 1,
name
=>
"test"
,
dir
=>
"."
);
ok(
$rc
,
"Verified - Real"
);
$rc
= Proc::PID::File->running(
verify
=>
"falsetest"
,
name
=>
"test"
,
dir
=>
"."
);
ok(!
$rc
,
"Verified - False"
);
ok(1,
"Done"
);