[systemd-devel] [PATCH] initial sysv-generator test suite

Martin Pitt martin.pitt at ubuntu.com
Tue Jan 20 07:19:24 PST 2015


Hello all,

We've had numerous problems with the SysV generator in the past, and
we just recently introduced another regression: init.d scripts which
end in ".sh" are now totally broken.

Thus I think it's high time to write some integration tests for that.
The attached patch provides the necessary framework and an initial set
of tests; e. g. test_multiple_provides() covers Michael's recent
commit b7e71846.

I can reproduce the ".sh" bug from above with a simple

|    def test_sh_suffix(self):
|        '''init.d script with .sh suffix'''
|
|        self.add_sysv('foo.sh', {}, enable=True)
|        err, results = self.run_generator()
|        [... actual checks here, not written yet ...]

which currently fails with

| ======================================================================
| FAIL: test_sh_suffix (__main__.SysvGeneratorTest)
| init.d script with .sh suffix
| ----------------------------------------------------------------------
| Traceback (most recent call last):
|   File "test/../test/sysv-generator-test.py", line 179, in test_sh_suffix
|     err, results = self.run_generator()
|   File "test/../test/sysv-generator-test.py", line 58, in run_generator
|     self.assertFalse('Fail' in err, err)
| AssertionError: True is not false : Looking for unit files in (higher priority first):
| 	/etc/systemd/system
| 	/run/systemd/system
| 	/usr/local/lib/systemd/system
| 	/lib/systemd/system
| 	/usr/lib/systemd/system
| Looking for SysV init scripts in:
| 	/tmp/sysv-gen-test.7qlq6kg2/init.d
| Looking for SysV rcN.d links in:
| 	/tmp/sysv-gen-test.7qlq6kg2
| Failed to create unit file /tmp/sysv-gen-test.7qlq6kg2/output/foo.service: File exists

Indeed it just creates a symlink pointing to itself and nothing else.
I will look into that actual bug in a bit, and write a complete test
along with it. But before I spend more work on the tests, I'd
appreciate a quick review of it whether the general structure is ok
for you.

As this deals with temp dirs, cleaning them up, running external
programs, parsing their output etc., I chose Python for this, as this
stuff is just soooo much faster and convenient to write. We already
have test/rule-syntax-check.py, so there's precedent :-)

As automake's tests are rather limited and require a single command
without arguments, but I want to make this obey configure's $(PYTHON)
and skip the test properly if python 3 is not available, I created a
simple shell wrapper around it.

Obviously this is still lacking a lot of important cases; I'm happy to
add them later on, I just wanted to get some initial generic feedback.

Thanks,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-test-add-initial-integration-test-for-systemd-sysv-g.patch
Type: text/x-diff
Size: 10434 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150120/2c0a3732/attachment.patch>


More information about the systemd-devel mailing list