Commit 3984b00b authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Randomize strings

parent 6ac288e0
......@@ -34,6 +34,7 @@ LICENSE: LGPL - see LICENSE file
CHANGELOG:
1.4.3 - Fix Random simulation (multiple clicks happened)
1.4.2 - Button to store TC in SQL database when available
1.4.1 - Align with DMT 2.1.x (major API update on pyside B mapper)
1.4.0 - Keep ASN.1 dash in the GUI (change of API)
......
......@@ -42,6 +42,10 @@ def compute_random_value(asn1_ty, pool):
return compute_random_sequence(basic, pool)
elif basic.kind in ('SequenceOfType', 'SetOfType'):
return compute_random_sequenceof(basic, pool)
elif basic.kind.endswith('StringType'):
return '"' + 'X' * random.randint(int(basic.Min), int(basic.Max)) + '"'
else:
raise NotImplementedError('Type not randomizable yet:' + basic.kind)
# Random values for basic types
......@@ -105,6 +109,10 @@ def compute_combinations(asn1_ty, pool):
elif basic.kind in ('SequenceOfType', 'SetOfType'):
for each in compute_sequenceof_combinations(basic, pool):
yield each
elif basic.kind.endswith('StringType'):
# Strings
for n in xrange(int(basic.Min), int(basic.Max) + 1):
yield '"' + 'X' * X + '"'
def compute_integer_combinations(asn1_ty, max_iter=0):
......
......@@ -16,7 +16,7 @@
__author__ = "Maxime Perrotin"
__license__ = "LGPLv3"
__version__ = "1.4.2"
__version__ = "1.4.3"
__url__ = "http://taste.tuxfamily.org"
import sys
......
......@@ -573,6 +573,14 @@ class sdlHandler(QObject):
ASN1_AST=ASN1_AST)
vals['editor'].updateVariable()
# Send a signal to click on the button
try:
# Remove all previously connected buttons to avoid
# clicking them all
self.clicker.disconnect()
except RuntimeError:
# Ignore - will trigger the first time only if no
# signal is currently connected.
pass
self.clicker.connect(vals['send_btn'].click)
self.clicker.emit()
......@@ -584,7 +592,6 @@ class sdlHandler(QObject):
for name, asn1_ty in self.sim_param['periodic']:
if asn1_ty:
arg = compute_random_value(asn1_ty, self.proc.dataview)
self.click_tc(name, arg)
# Select randomly an active TC and call it
try:
random_tc, asn1_ty = random.choice(list(self.sim_param['random']))
......@@ -602,7 +609,7 @@ class sdlHandler(QObject):
self.click_tc(random_tc, arg)
# Send a message every 100 ms.. Should be configurable
QTimer().singleShot(1000, self.random_step)
QTimer().singleShot(100, self.random_step)
def exhaustive_simulation(self):
''' Model checker - try all combinations of all inputs in all
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment