]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: give systemd chance to actually start the unit
authorFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 3 Feb 2020 12:07:45 +0000 (13:07 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 8 Feb 2020 10:38:24 +0000 (11:38 +0100)
In certain cases the expected enqueue-start-replace-continue
sequence would end up as enqueue-replace-start-continue which causes
unexpected fails even though the serialization/deserialization part
works as expected. As we can't use `--wait` in this case, let's give
sysetmd a second to actually start the unit before replacing it with
another one.

Also, switch from the single-letter test output to a bit verbose format.

Fixes: #14632
test/test-exec-deserialization.py

index a11c5ecbf02de273596f523d957ce2d0673fe080..8aa16fb7f94838201d1e82bb6d9a31e046965409 100755 (executable)
@@ -11,6 +11,7 @@ import time
 import os
 import tempfile
 import subprocess
+import sys
 
 from enum import Enum
 
@@ -32,7 +33,7 @@ class ExecutionResumeTest(unittest.TestCase):
         unit_file_content = '''
         [Service]
         Type=oneshot
-        ExecStart=/bin/sleep 2
+        ExecStart=/bin/sleep 3
         ExecStart=/bin/bash -c "echo foo >> {0}"
         '''.format(self.output_file)
         self.unit_files[UnitFileChange.NO_CHANGE] = unit_file_content
@@ -41,7 +42,7 @@ class ExecutionResumeTest(unittest.TestCase):
         [Service]
         Type=oneshot
         ExecStart=/bin/bash -c "echo foo >> {0}"
-        ExecStart=/bin/sleep 2
+        ExecStart=/bin/sleep 3
         '''.format(self.output_file)
         self.unit_files[UnitFileChange.LINES_SWAPPED] = unit_file_content
 
@@ -49,7 +50,7 @@ class ExecutionResumeTest(unittest.TestCase):
         [Service]
         Type=oneshot
         ExecStart=/bin/bash -c "echo bar >> {0}"
-        ExecStart=/bin/sleep 2
+        ExecStart=/bin/sleep 3
         ExecStart=/bin/bash -c "echo foo >> {0}"
         '''.format(self.output_file)
         self.unit_files[UnitFileChange.COMMAND_ADDED_BEFORE] = unit_file_content
@@ -57,7 +58,7 @@ class ExecutionResumeTest(unittest.TestCase):
         unit_file_content = '''
         [Service]
         Type=oneshot
-        ExecStart=/bin/sleep 2
+        ExecStart=/bin/sleep 3
         ExecStart=/bin/bash -c "echo foo >> {0}"
         ExecStart=/bin/bash -c "echo bar >> {0}"
         '''.format(self.output_file)
@@ -67,7 +68,7 @@ class ExecutionResumeTest(unittest.TestCase):
         [Service]
         Type=oneshot
         ExecStart=/bin/bash -c "echo baz >> {0}"
-        ExecStart=/bin/sleep 2
+        ExecStart=/bin/sleep 3
         ExecStart=/bin/bash -c "echo foo >> {0}"
         ExecStart=/bin/bash -c "echo bar >> {0}"
         '''.format(self.output_file)
@@ -107,6 +108,7 @@ class ExecutionResumeTest(unittest.TestCase):
     def setup_unit(self):
         self.write_unit_file(UnitFileChange.NO_CHANGE)
         subprocess.check_call(['systemctl', '--job-mode=replace', '--no-block', 'start', self.unit])
+        time.sleep(1)
 
     def test_no_change(self):
         expected_output = 'foo\n'
@@ -207,4 +209,4 @@ class ExecutionResumeTest(unittest.TestCase):
         self.reload()
 
 if __name__ == '__main__':
-    unittest.main()
+    unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=3))