diff options
author | Daniele Nicolodi <daniele@grinta.net> | 2018-06-16 10:55:56 -0600 |
---|---|---|
committer | Daniele Nicolodi <daniele@grinta.net> | 2018-06-16 11:19:14 -0600 |
commit | efd04acfacb2df6455f1b389d6f7092dba18ff52 (patch) | |
tree | 56d5f7d8ad65a02668f800d173ae33eb339a0eaa /t/dh_installsystemd | |
parent | 8ad60a1245fe2e6a0ddc0bc94e8b1145b8baf0a2 (diff) | |
download | debhelper-efd04acfacb2df6455f1b389d6f7092dba18ff52.tar.gz |
t/dh_installsystemd: Add tests for a simpler source package
Extend the tests to verify that dh_installsystemd comand line
arguments handling works in the simplified form allowed by source
packages building only one binary package.
Diffstat (limited to 't/dh_installsystemd')
-rwxr-xr-x | t/dh_installsystemd/dh_installsystemd.t | 57 | ||||
-rw-r--r-- | t/dh_installsystemd/simple/debian/changelog | 5 | ||||
-rw-r--r-- | t/dh_installsystemd/simple/debian/control | 10 | ||||
-rw-r--r-- | t/dh_installsystemd/simple/debian/foo.service | 8 |
4 files changed, 71 insertions, 9 deletions
diff --git a/t/dh_installsystemd/dh_installsystemd.t b/t/dh_installsystemd/dh_installsystemd.t index 7f3a8764..b18b9029 100755 --- a/t/dh_installsystemd/dh_installsystemd.t +++ b/t/dh_installsystemd/dh_installsystemd.t @@ -8,14 +8,7 @@ use Test::DH; use File::Path qw(remove_tree make_path); use Debian::Debhelper::Dh_Lib qw(!dirname); -our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( - debian/changelog - debian/control - debian/foo.service - debian/foo2.service -)); - -plan(tests => 1); +plan(tests => 2); sub unit_is_enabled { my ($package, $unit, $num_enables, $num_masks) = @_; @@ -34,6 +27,7 @@ sub unit_is_enabled { $matches = grep { m{deb-systemd-helper mask.*'\Q$unit\E\.service'} } @output; ok($matches == $num_masks) or diag("$unit appears to have been masked $matches times (expected $num_masks)"); } + sub unit_is_started { my ($package, $unit, $num_starts, $num_stops) = @_; my @output; @@ -49,7 +43,52 @@ sub unit_is_started { ok($matches == $num_stops) or diag("$unit appears to have been stopped $matches times (expected $num_stops)"); } -# Units are installed and enabled + +# +# Test a simple source package defining a single binary package +# +our $TEST_DH_FIXTURE_DIR = 'simple'; +our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( + debian/changelog + debian/control + debian/foo.service +)); + +each_compat_subtest { + ok(run_dh_tool('dh_installsystemd')); + ok(-e 'debian/foo/lib/systemd/system/foo.service'); + ok(find_script('foo', 'postinst')); + unit_is_enabled('foo', 'foo', 1); + unit_is_started('foo', 'foo', 1); + ok(run_dh_tool('dh_clean')); + + ok(run_dh_tool('dh_installsystemd', '--no-start')); + ok(-e 'debian/foo/lib/systemd/system/foo.service'); + ok(find_script('foo', 'postinst')); + unit_is_enabled('foo', 'foo', 1); + unit_is_started('foo', 'foo', 0, 1); + ok(run_dh_tool('dh_clean')); + + ok(run_dh_tool('dh_installsystemd', '--no-start', 'foo.service')); + ok(-e 'debian/foo/lib/systemd/system/foo.service'); + ok(find_script('foo', 'postinst')); + unit_is_enabled('foo', 'foo', 1); + unit_is_started('foo', 'foo', 0, 1); + ok(run_dh_tool('dh_clean')); +}; + + +# +# Test a more complex source package defining three binary packages +# +our $TEST_DH_FIXTURE_DIR = '.'; +our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( + debian/changelog + debian/control + debian/foo.service + debian/foo2.service +)); + each_compat_subtest { ok(run_dh_tool( 'dh_installsystemd')); ok(-e "debian/foo/lib/systemd/system/foo.service"); diff --git a/t/dh_installsystemd/simple/debian/changelog b/t/dh_installsystemd/simple/debian/changelog new file mode 100644 index 00000000..5b1a8fee --- /dev/null +++ b/t/dh_installsystemd/simple/debian/changelog @@ -0,0 +1,5 @@ +foo (1.0-1) unstable; urgency=low + + * Initial release. (Closes: #XXXXXX) + + -- Test <test@example.org> Mon, 11 Jul 2016 18:10:59 +0200 diff --git a/t/dh_installsystemd/simple/debian/control b/t/dh_installsystemd/simple/debian/control new file mode 100644 index 00000000..4f4238eb --- /dev/null +++ b/t/dh_installsystemd/simple/debian/control @@ -0,0 +1,10 @@ +Source: foo +Section: misc +Priority: optional +Maintainer: Test <testing@nowhere> +Standards-Version: 3.9.8 + +Package: foo +Architecture: all +Description: package foo + Package foo diff --git a/t/dh_installsystemd/simple/debian/foo.service b/t/dh_installsystemd/simple/debian/foo.service new file mode 100644 index 00000000..2b48a781 --- /dev/null +++ b/t/dh_installsystemd/simple/debian/foo.service @@ -0,0 +1,8 @@ +[Unit] +Description=A unit + +[Service] +ExecStart=/bin/true + +[Install] +WantedBy=multi-user.target |