diff options
author | Felipe Sateler <fsateler@debian.org> | 2017-10-09 19:52:08 -0300 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2017-10-13 18:08:29 +0000 |
commit | cb77b915bae10d04057901abf6cfbfa82aa409b1 (patch) | |
tree | ecce9c878bd97db2cd4d385386e7af6e1dd1241f /t/dh_installsystemd | |
parent | 4d8cf64de4a65f3cd99de6529028f2415ca3fdd7 (diff) | |
download | debhelper-cb77b915bae10d04057901abf6cfbfa82aa409b1.tar.gz |
More tests for dh_installsystemd
Diffstat (limited to 't/dh_installsystemd')
-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 { |