Holger Hans Peter Freyther | c490cde | 2018-02-25 21:24:30 +0000 | [diff] [blame] | 1 | # osmo_ms_driver: Main test runner |
| 2 | # |
| 3 | # Copyright (C) 2018 by Holger Hans Peter Freyther |
| 4 | # |
| 5 | # This program is free software: you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as |
| 7 | # published by the Free Software Foundation, either version 3 of the |
| 8 | # License, or (at your option) any later version. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | # Local modules |
| 19 | from .event_server import EventServer |
| 20 | from .simple_loop import SimpleLoop |
| 21 | from .location_update_test import MassUpdateLocationTest |
| 22 | from .cdf import ease_in_out_duration, linear_with_duration |
| 23 | from osmo_gsm_tester import log |
| 24 | |
| 25 | # System modules |
| 26 | import datetime |
| 27 | import subprocess |
| 28 | import signal |
| 29 | import tempfile |
| 30 | import os.path |
| 31 | |
| 32 | |
| 33 | def main(): |
| 34 | # Create a default log to stdout |
| 35 | log.LogTarget().style(src=False) |
| 36 | |
| 37 | # We don't care what is happening to child processes we spawn! |
| 38 | signal.signal(signal.SIGCHLD, signal.SIG_IGN) |
| 39 | |
| 40 | loop = SimpleLoop() |
| 41 | |
| 42 | # TODO: Parse parameters and test composition. Right now we test |
| 43 | # with a single set of values. |
| 44 | num_ms = 10 |
| 45 | |
| 46 | tmp_dir = tempfile.mkdtemp(suffix="osmo-ms-driver") |
| 47 | log.log("Going to store files in ", tmp_dir=tmp_dir) |
| 48 | |
| 49 | # How long should starting all apps take |
| 50 | time_start=datetime.timedelta(seconds=60) |
| 51 | # In which steps to start processes |
| 52 | time_step=datetime.timedelta(milliseconds=100) |
| 53 | |
| 54 | # Event server path |
| 55 | event_server_path = os.path.join(tmp_dir, "osmo_ms_driver.unix") |
| 56 | |
| 57 | # The function that decides when to start something |
| 58 | cdf = ease_in_out_duration(time_start, time_step) |
| 59 | |
| 60 | # Event server to handle MS->test events |
| 61 | ev_server = EventServer("ev_server", event_server_path) |
| 62 | ev_server.listen(loop) |
| 63 | #while True: |
| 64 | # loop.select() |
| 65 | |
| 66 | # Just a single test for now. |
| 67 | test = MassUpdateLocationTest("lu_test", num_ms, cdf, ev_server, tmp_dir) |
| 68 | |
| 69 | # Run until everything has been launched |
| 70 | test.launch(loop) |
| 71 | |
| 72 | # Wait for it to complete |
| 73 | test.wait_for_result(loop) |
| 74 | |
| 75 | # Print stats |
| 76 | test.print_stats() |
| 77 | |
| 78 | if __name__ == '__main__': |
| 79 | main() |