diff options
-rwxr-xr-x | t/dh_installsystemd/dh_installsystemd.t | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/t/dh_installsystemd/dh_installsystemd.t b/t/dh_installsystemd/dh_installsystemd.t index 6ea34a79..5dda10ef 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 { |