diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/mozbase/mozrunner/tests/test_threads.py | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozbase/mozrunner/tests/test_threads.py')
-rw-r--r-- | testing/mozbase/mozrunner/tests/test_threads.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/testing/mozbase/mozrunner/tests/test_threads.py b/testing/mozbase/mozrunner/tests/test_threads.py new file mode 100644 index 0000000000..fa77d92688 --- /dev/null +++ b/testing/mozbase/mozrunner/tests/test_threads.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +import mozunit + + +def test_process_start_via_thread(runner, create_thread): + """Start the runner via a thread""" + thread = create_thread(runner, True, 2) + + thread.start() + thread.join() + + assert runner.is_running() + + +def test_process_stop_via_multiple_threads(runner, create_thread): + """Stop the runner via multiple threads""" + runner.start() + threads = [] + for i in range(5): + thread = create_thread(runner, False, 5) + threads.append(thread) + thread.start() + + # Wait until the process has been stopped by another thread + for thread in threads: + thread.join() + returncode = runner.wait(1) + + assert returncode not in [None, 0] + assert runner.returncode == returncode + assert runner.process_handler is not None + assert runner.wait(2) == returncode + + +def test_process_post_stop_via_thread(runner, create_thread): + """Stop the runner and try it again with a thread a bit later""" + runner.start() + thread = create_thread(runner, False, 5) + thread.start() + + # Wait a bit to start the application gets started + runner.wait(1) + returncode = runner.stop() + thread.join() + + assert returncode not in [None, 0] + assert runner.returncode == returncode + assert runner.process_handler is not None + assert runner.wait(2) == returncode + + +if __name__ == "__main__": + mozunit.main() |