[debhelper-devel] [debhelper] 15/21: More tests for dh_installsystemd
Niels Thykier
nthykier at moszumanska.debian.org
Fri Oct 13 18:27:21 UTC 2017
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository debhelper.
commit cb77b915bae10d04057901abf6cfbfa82aa409b1
Author: Felipe Sateler <fsateler at debian.org>
Date: Mon Oct 9 19:52:08 2017 -0300
More tests for dh_installsystemd
---
t/dh_installsystemd/dh_installsystemd.t | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/t/dh_installsystemd/dh_installsystemd.t b/t/dh_installsystemd/dh_installsystemd.t
index 6ea34a7..5dda10e 100755
--- a/t/dh_installsystemd/dh_installsystemd.t
+++ b/t/dh_installsystemd/dh_installsystemd.t
@@ -33,15 +33,16 @@ sub unit_is_enabled {
ok($matches == $num_enables) or diag("$unit appears to have been masked $matches times (expected $num_enables)");
}
sub unit_is_started {
- my ($package, $unit, $num_starts) = @_;
+ my ($package, $unit, $num_starts, $num_stops) = @_;
my @output;
my $matches;
+ $num_stops = $num_stops // $num_starts;
@output=`cat debian/$package.postinst.debhelper`;
$matches = grep { m{deb-systemd-invoke \$_dh_action .*$unit.service} } @output;
ok($matches == $num_starts) or diag("$unit appears to have been started $matches times (expected $num_starts)");
@output=`cat debian/$package.prerm.debhelper`;
$matches = grep { m{deb-systemd-invoke stop .*$unit.service} } @output;
- ok($matches == $num_starts) or diag("$unit appears to have been started $matches times (expected $num_starts)");
+ ok($matches == $num_stops) or diag("$unit appears to have been stopped $matches times (expected $num_stops)");
}
# Units are installed and enabled
@@ -65,6 +66,30 @@ each_compat_from_and_above_subtest(11, sub {
unit_is_enabled('foo', 'foo2', 1);
unit_is_started('foo', 'foo2', 1);
ok(run_dh_tool('dh_clean'));
+
+ make_path('debian/foo/lib/systemd/system/');
+ install_file('debian/foo2.service', 'debian/foo/lib/systemd/system/foo2.service');
+ ok(run_dh_tool({ 'needs_root' => 1 }, 'dh_installsystemd', '--no-start'));
+ ok(-e "debian/foo/lib/systemd/system/foo.service");
+ ok(-e "debian/foo.postinst.debhelper");
+ unit_is_enabled('foo', 'foo', 1);
+ unit_is_started('foo', 'foo', 0, 1); # present units are stopped on remove even if no start
+ unit_is_enabled('foo', 'foo2', 1);
+ unit_is_started('foo', 'foo2', 0, 1);
+ ok(run_dh_tool('dh_clean'));
+
+ make_path('debian/foo/lib/systemd/system/');
+ install_file('debian/foo2.service', 'debian/foo/lib/systemd/system/foo2.service');
+ ok(run_dh_tool({ 'needs_root' => 1 }, 'dh_installsystemd', '--no-start', 'debian/foo.service'));
+ ok(run_dh_tool({ 'needs_root' => 1 }, 'dh_installsystemd', '-p', 'foo', 'foo2.service'));
+ ok(-e "debian/foo/lib/systemd/system/foo.service");
+ ok(-e "debian/foo.postinst.debhelper");
+ unit_is_enabled('foo', 'foo', 1);
+ unit_is_started('foo', 'foo', 0, 1);
+ unit_is_enabled('foo', 'foo2', 1);
+ unit_is_started('foo', 'foo2', 1);
+ ok(run_dh_tool('dh_clean'));
+
});
each_compat_up_to_and_incl_subtest(10, sub {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git
More information about the debhelper-devel
mailing list