summaryrefslogtreecommitdiff
path: root/t/dh_installinit/dh_installinit.t
blob: d05c207436636f8feadacac86f73fd4b870b449b (plain)
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
57
#!/usr/bin/perl
use strict;
use Test::More;
use File::Basename ();

# Let the tests be run from anywhere, but current directory
# is expected to be the one where this test lives in.
chdir File::Basename::dirname($0) or die "Unable to chdir to ".File::Basename::dirname($0);

my $TOPDIR = "../..";
my $rootcmd;

if ($< == 0) {
	$rootcmd = '';
}
else {
	system("fakeroot true 2>/dev/null");
	$rootcmd = $? ? undef : 'fakeroot';
}

if (not defined($rootcmd)) {
	plan skip_all => 'fakeroot required';
}
else {
	plan(tests => 5);
}

system("$TOPDIR/dh_clean");

my $service = "debian/foo.service";

system("mkdir -p debian/foo debian/bar debian/baz");
system("$rootcmd $TOPDIR/dh_installinit");
ok(-e "debian/foo/lib/systemd/system/foo.service");
ok(-e "debian/foo.postinst.debhelper");
system("$TOPDIR/dh_clean");

system("mkdir -p debian/foo debian/bar debian/baz");
system("DH_COMPAT=11 $rootcmd $TOPDIR/dh_installinit");
ok(! -e "debian/foo/lib/systemd/system/foo.service");
ok(! -e "debian/foo.postinst.debhelper");
system("$TOPDIR/dh_clean");

system("mkdir -p debian/foo debian/bar debian/baz");
system("mkdir -p debian/foo/lib/systemd/system/");
system("cp debian/foo.service debian/foo/lib/systemd/system/");
system("DH_COMPAT=11 $rootcmd $TOPDIR/dh_installinit");
ok(! -e "debian/foo.postinst.debhelper");
system("$TOPDIR/dh_clean");

system("$TOPDIR/dh_clean");

# Local Variables:
# indent-tabs-mode: t
# tab-width: 4
# cperl-indent-level: 4
# End: