Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e3b7f9

Browse files
committed
Allow CPS to be a function of run time (i.e. time in seconds since
test began) when arguments starts with "=".
1 parent d6daf87 commit 7e3b7f9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

alice_main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2626
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28-
import sys
28+
import sys, getopt
29+
import math
30+
from time import sleep
2931

3032
from .contrib.objgraph import show_most_common_types
3133

@@ -116,7 +118,12 @@ def main_func():
116118
tcfg.continuous = True
117119
continue
118120
if o == '-C':
119-
tcfg.cps = float(a)
121+
if not a.startswith('='):
122+
cpsval = float(a)
123+
tcfg.cps = lambda now: cpsval
124+
else:
125+
cpsfunc = eval(F'lambda now: {a[1:]}')
126+
tcfg.cps = cpsfunc
120127
continue
121128
if len(ttype) > 0:
122129
tcfg.ttype = tuple(ttype)

lib/alice_testcore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from sippy.SipTransactionManager import SipTransactionManager
3131
from sippy.Signal import Signal
3232
from sippy.Time.Timeout import Timeout, TimeoutAbsMono
33-
from sippy.Time.MonoTime import MonoTime
3433
from sippy.Core.EventDispatcher import ED2
3534
from sippy.Math.recfilter import recfilter
3635
from random import shuffle, choice
@@ -170,7 +169,7 @@ def runnext(self):
170169
subtest = subtest_cfg.init_test()
171170
self.nsubtests_running += 1
172171
if self.tcfg.cps != None:
173-
self.ntime.offset(1.0 / self.tcfg.cps)
172+
self.ntime.offset(1.0 / self.tcfg.cps(self.ntime - self.tcfg.ntime))
174173
self.nextr = TimeoutAbsMono(self.runnext, self.ntime)
175174
else:
176175
self.runnext()

0 commit comments

Comments
 (0)