summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLars Kellogg-Stedman <lars@redhat.com>2015-06-03 13:18:38 -0400
committerLars Kellogg-Stedman <lars@redhat.com>2015-06-03 13:18:38 -0400
commit8db399f9149a81de5d65f0759792766ecd509ab3 (patch)
tree2ed1a8107b500e84a92382f1b8f5c2fc592a72ff /tests
parent2a955375dbf0d546d8999793923c4e8f23e042c6 (diff)
downloadvyos-cloud-init-8db399f9149a81de5d65f0759792766ecd509ab3.tar.gz
vyos-cloud-init-8db399f9149a81de5d65f0759792766ecd509ab3.zip
add tests for systemd detection
This adds the following tests in test_distros.test_generic: - test_systemd_in_use Test the situation in which /run/systemd/system exists. - test_systemd_not_in_use Test the situation in which /run/systemd/system does not exists. - test_systemd_symlink This tests the situation in which /run/systemd/system exists but is a *symlink* to a directory, which according to sd_booted() should return false.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_distros/test_generic.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unittests/test_distros/test_generic.py b/tests/unittests/test_distros/test_generic.py
index 35153f0d..8e3bd78a 100644
--- a/tests/unittests/test_distros/test_generic.py
+++ b/tests/unittests/test_distros/test_generic.py
@@ -194,6 +194,29 @@ class TestGenericDistro(helpers.FilesystemMockingTestCase):
{'primary': 'http://fs-primary-intel',
'security': 'http://security-mirror2-intel'})
+ def test_systemd_in_use(self):
+ cls = distros.fetch("ubuntu")
+ d = cls("ubuntu", {}, None)
+ self.patchOS(self.tmp)
+ self.patchUtils(self.tmp)
+ os.makedirs('/run/systemd/system')
+ self.assertTrue(d.uses_systemd())
+
+ def test_systemd_not_in_use(self):
+ cls = distros.fetch("ubuntu")
+ d = cls("ubuntu", {}, None)
+ self.patchOS(self.tmp)
+ self.patchUtils(self.tmp)
+ self.assertFalse(d.uses_systemd())
+
+ def test_systemd_symlink(self):
+ cls = distros.fetch("ubuntu")
+ d = cls("ubuntu", {}, None)
+ self.patchOS(self.tmp)
+ self.patchUtils(self.tmp)
+ os.makedirs('/run/systemd')
+ os.symlink('/', '/run/systemd/system')
+ self.assertFalse(d.uses_systemd())
# def _get_package_mirror_info(mirror_info, availability_zone=None,
# mirror_filter=util.search_for_mirror):