blob: f1c34fb24a0cde35f4515b6b1e4601e1c85bce4d [file] [log] [blame]
Holger Hans Peter Freyther574e62f2018-06-20 09:15:15 +01001# osmo_ms_driver: Test helpers and base classes
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
18from osmo_gsm_tester import log
19
20def imsi_ki_gen():
21 """
22 Generate IMSIs and KIs to be used by test.
23 """
24 n = 1010000000000
25 while True:
26 yield ("%.15d" % n, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
27 n += 1
28
29class Results(log.Origin):
30 """
31 A base class to collect results from tests.
32 """
33
34 def __init__(self, name):
35 super().__init__(log.C_RUN, name)
36 self._time_of_registration = None
37 self._time_of_launch = None
38
39 def set_start_time(self, time):
40 assert self._time_of_registration is None
41 self._time_of_registration = time
42
43 def set_launch_time(self, time):
44 assert self._time_of_launch is None
45 self._time_of_launch = time
46
47 def start_time(self):
48 return self._time_of_registration or 0
49
50 def launch_time(self):
51 return self._time_of_launch or 0