diff options
author | Daniele Nicolodi <daniele@grinta.net> | 2018-06-14 15:12:01 -0600 |
---|---|---|
committer | Daniele Nicolodi <daniele@grinta.net> | 2018-06-20 23:29:11 -0600 |
commit | 8500f9be52469284c1db2ffe8bc5a1cc8ef533ca (patch) | |
tree | c255b00f0f1b996d7bcc4d900d7cc0f68b1f03d2 /t/dh_installsystemd | |
parent | 51f0a5d45d50305368effb08faaa37eadfb5595c (diff) | |
download | debhelper-8500f9be52469284c1db2ffe8bc5a1cc8ef533ca.tar.gz |
dh_installsystemd: Fix handling of symlinked alias units, add relevant tests
Diffstat (limited to 't/dh_installsystemd')
-rwxr-xr-x | t/dh_installsystemd/dh_installsystemd.t | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/t/dh_installsystemd/dh_installsystemd.t b/t/dh_installsystemd/dh_installsystemd.t index cc37bf2e..0604a39f 100755 --- a/t/dh_installsystemd/dh_installsystemd.t +++ b/t/dh_installsystemd/dh_installsystemd.t @@ -10,6 +10,17 @@ use Debian::Debhelper::Dh_Lib qw(!dirname); plan(tests => 2); +sub write_file { + my ($path, $content) = @_; + + my $dir = dirname($path); + install_dir($dir); + + open(my $fd, '>>', $path) or error("open($path) failed: $!"); + print {$fd} $content . '\n'; + close($fd) or error("close($path) failed: $!"); +} + sub unit_is_enabled { my ($package, $unit, $num_enables, $num_masks) = @_; my @output; @@ -175,6 +186,29 @@ each_compat_subtest { 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/foo.service', 'debian/foo/lib/systemd/system/target.service'); + make_symlink_raw_target('target.service', 'debian/foo/lib/systemd/system/source.service'); + ok(run_dh_tool('dh_installsystemd')); + unit_is_enabled('foo', 'foo', 1); + # Alias= realized by symlinks are not enabled in maintaner scripts + unit_is_enabled('foo', 'source', 0); + unit_is_enabled('foo', 'target', 1); + ok(run_dh_tool('dh_clean')); + make_path('debian/foo/lib/systemd/system/'); + make_path('debian/foo/etc/init.d/'); + install_file('debian/foo.service', 'debian/foo/lib/systemd/system/target.service'); + make_symlink_raw_target('target.service', 'debian/foo/lib/systemd/system/source.service'); + write_file('debian/foo/etc/init.d/source', '# something'); + ok(run_dh_tool('dh_installsystemd')); + unit_is_enabled('foo', 'foo', 1); + # Alias= realized by symlinks are not enabled in maintaner scripts + unit_is_enabled('foo', 'source', 0); + unit_is_enabled('foo', 'target', 1); + # The presence of a sysvinit script for the alias unit inhibits start of both + unit_is_started('foo', 'source', 0); + unit_is_started('foo', 'target', 0); + ok(run_dh_tool('dh_clean')); +}; |