File: 01_lsb_file_with_init_config.t

package info (click to toggle)
libdaemon-control-perl 0.001006-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 248 kB
  • ctags: 147
  • sloc: perl: 2,244; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,311 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
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;

my ( $file, $ilib );

# Let's make it so people can test in t/ or in the dist directory.
if ( -f 't/bin/01_lsb_02.pl' ) { # Dist Directory.
    $file = "t/bin/01_lsb_02.pl";
    $ilib = "lib";
} elsif ( -f 'bin/01_lsb_02.pl' ) {
    $file = "bin/01_lsb_02.pl";
    $ilib = "../lib";
} else {
    die "Tests should be run in the dist directory or t/";
}


open my $lf, "-|", $^X, "-I$ilib", $file, "get_init_file"
    or die "Failed to open pipe to $file: $!";
my $content = do { local $/; <$lf> };
close $lf;

my $content_expected = do { local $/; <DATA> };

like $content, qr/$content_expected/, "LSB File Generation Works.";

done_testing;

__DATA__
#!/bin/sh

# Generated at [\w: ]+ with Daemon::Control (?:DEV|[\d.]+)

### BEGIN INIT INFO
# Provides:          My Daemon
# Required-Start:    \$syslog \$remote_fs
# Required-Stop:     \$syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: My Daemon Short
# Description:       My Daemon controls the My Daemon daemon.
### END INIT INFO`

\[ -r /etc/default/my_program \] && . /etc/default/my_program



if \[ -x /usr/sbin/mydaemon/init.pl \];
then
    /usr/sbin/mydaemon/init.pl \$1
else
    echo "Required program /usr/sbin/mydaemon/init.pl not found!"
    exit 1;
fi