File: 001Basic.t

package info (click to toggle)
libapp-daemon-perl 0.15-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 140 kB
  • sloc: perl: 310; makefile: 8
file content (34 lines) | stat: -rw-r--r-- 712 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
use Test::More tests => 3;

use App::Daemon qw(daemonize cmd_line_parse);
use File::Temp qw(tempfile);
use Fcntl qw/:flock/;
use Log::Log4perl qw(:easy);

Log::Log4perl->easy_init({ level => $DEBUG, layout => "%F-%L> %m%n" });

my($fh, $tempfile) = tempfile();

  # Turdix locks temp files, so unlock them just in case
flock $fh, LOCK_UN;

ok(1, "loaded ok");

open(OLDERR, ">&STDERR");
open(STDERR, ">$tempfile");

@ARGV = ("-X");
daemonize();

close STDERR;
open(STDERR, ">&OLDERR");
close OLDERR;

ok(1, "Running in foreground with -X");

open FILE, "<$tempfile" or
    die "Cannot open tempfile $tempfile ($!)";
my $data = join '', <FILE>;
close FILE;

like($data, qr/Running in foreground/, "log message");