#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
#
-# Copyright 2017 Michal Sekletar <msekleta@redhat.com>
-#
-# systemd is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2.1 of the License, or
-# (at your option) any later version.
-#
-# systemd is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with systemd; If not, see <http://www.gnu.org/licenses/>.
+# Copyright © 2017 Michal Sekletar <msekleta@redhat.com>
# ATTENTION: This uses the *installed* systemd, not the one from the built
# source tree.
import os
import tempfile
import subprocess
+import sys
from enum import Enum
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
[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
[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
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)
[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)
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'
self.reload()
if __name__ == '__main__':
- unittest.main()
+ unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=3))