def randomize(self): rnd = randomizer.randint(0, 1) if rnd == 0: self.local_declarations_list = [] else: rndl = randomizer.randint(self.min_list_size, self.max_list_size) for x in range(0, rndl): _method_prototype = method_prototype() _method_prototype.randomize() self.prototypes_list.append(_method_prototype)
def randomize(self): rnd = randomizer.randint(0, 1) if rnd == 0: self.list = [] else: rndl = randomizer.randint(self.min_list_size, self.max_list_size) for x in range(0, rndl): _statement_or_declaration = statement_or_declaration() _statement_or_declaration.randomize() self.list.append(_statement_or_declaration)
def randomize(self): rnd = randomizer.randint(0, 1) if rnd == 0: self.non_empty_parameter_list = [] else: rndl = randomizer.randint(self.min_list_size, self.max_list_size) for x in range(0, rndl): _parser_local_element = parser_local_element() _parser_local_element.randomize() self.parser_local_elements_list.append(_parser_local_element)
def randomize(self): rnd = randomizer.randint(0, 1) if rnd == 0: self.case_list = [] else: rndl = randomizer.randint(self.min_list_size, self.max_list_size) for x in range(0, rndl): _select_case = select_case() _select_case.randomize() self.case_list.append(_select_case)
def randomize(self): rnd = randomizer.randint(0, 1) if rnd == 0: self.local_declarations_list = [] else: rndl = randomizer.randint(self.min_list_size, self.max_list_size) for x in range(0, rndl): _control_local_declaration = control_local_declaration() _control_local_declaration.randomize() self.local_declarations_list.append(_control_local_declaration)
def randomize(self): _annotation = annotation() _annotation.randomize() self.annotation = _annotation self.name = self.generate_name() self.identifiers = self.generate_identifiers( randomizer.randint(self.field_min_number, self.field_max_number))
def randomize(self): common.usedRandomize() rnd = randomizer.randint(0, len(scope.get_available_actions())-1) for x in range(0, rnd): _action = action_ref(force_action=x) _action.randomize() self._action_list.append(_action)
def randomize(self): rnd = randomizer.randint(0, 1) if rnd == 0: self.state_expression = None else: self.state_expression = state_expression() self.state_expression.randomize()
def randomize(self): while True: self.value = common.get_random_string( randomizer.randint(self.min_identifier_length, self.max_identifier_length), False) if not self.filter(): break
def randomize(self): common.usedRandomize() available_parameters = scope.get_available_parameters(["struct", "header"]) if len(available_parameters): self.parameter = available_parameters.keys()[randomizer.randint(0, len(available_parameters) - 1)] _parameter = available_parameters[self.parameter]["object"].type_ref.get_type_decl() if len(_parameter.struct_field_list.field_list): _field_list = [] for _field in _parameter.struct_field_list.field_list: if _field.type_ref.type == 0 and _field.type_ref.get_ref_type() != "varbit": _field_list.append(_field) if len(_field_list): self.member = _field_list[randomizer.randint(0, len(_field_list) - 1)] self.name = self.algorithms[randomizer.randint(0, len(self.algorithms) - 1)] self.opt_annotations = opt_annotations() self.opt_annotations.randomize()
def randomize(self): rnd = randomizer.randint(0, 1) if rnd == 0: self.type_parameter_list = None else: self.type_parameter_list = type_parameter_list() self.type_parameter_list.randomize()
def randomize(self): rnd = randomizer.randint(self.min_random_actions, self.max_random_actions) for x in range(0, rnd): _action_declaration = action_declaration() _action_declaration.randomize() self.action_declarations.append(_action_declaration) scope.insert_action(_action_declaration.name.generate_code(), _action_declaration) rnd = randomizer.randint(self.min_random_tables, self.max_random_tables) for x in range(0, rnd): _table_declaration = table_declaration() _table_declaration.randomize() self.table_declarations.append(_table_declaration) scope.insert_table(_table_declaration.name.generate_code(), _table_declaration)
def randomize(self, headers): common.usedRandomize() _annotation = annotation() _annotation.randomize() self.annotation = _annotation self.name = self.generate_name() self.headers = randomizer.sample(headers, randomizer.randint(0, len(headers)))
def randomize(self): common.usedRandomize() rnd = randomizer.randint(0, 1) if rnd == 0: self.non_empty_arg_list = None else: self.non_empty_arg_list = non_empty_arg_list() self.non_empty_arg_list.randomize()
def randomize(self): common.usedRandomize() self.keyset_expression = keyset_expression() self.keyset_expression.randomize() available_states = scope.get_available_states() self.name = available_states.keys()[randomizer.randint( 0, len(available_states) - 1)]
def randomize(self): self.switch_label = switch_label() self.switch_label.randomize() rnd = randomizer.randint(0, 1) if rnd == 0: self.block_statement = None elif rnd == 1: from block_statement import block_statement self.block_statement = block_statement() self.block_statement.randomize()
def randomize(self): self.type = randomizer.getRandom(self.probabilities) if self.type == 0: self.field_list = [] else: rndl = randomizer.randint(self.min_list_size, self.max_list_size) for x in range(0, rndl): _struct_field = struct_field(fromObj=self.fromObj) _struct_field.randomize() self.field_list.append(_struct_field)
def generate_base_expression(self, type): if type == 'bool': values = ['true', 'false'] return randomizer.choice(values) if type == 'string': return '"' + common.get_random_string( randomizer.randint(self.string_min_length, self.string_max_length), False) + '"' if type == 'arithmetic': return common.get_random_number(self.numeric_min_size, self.numeric_max_size)
def randomize(self): self.type = randomizer.getRandom(self.probabilities) if self.type == 0: self.element_list = [] else: rndl = randomizer.randint(self.min_list_size, self.max_list_size) for x in range(0, rndl): _key_element = key_element() _key_element.randomize() if _key_element.member is not None: self.element_list.append(_key_element)
def randomize(self): common.usedRandomize() while True: self.type_ref = type_ref(force_type=0) self.type_ref.randomize() available_variables = scope.get_available_variables(only_types=self.type_ref.get_ref_type()) if len(available_variables): self.lvalue = available_variables.keys()[randomizer.randint(0, len(available_variables) - 1)] self.expression = self.type_ref.value.generate_literal() if not self.filter(): break
def randomize(self): rnd = randomizer.randint(0, 3) if rnd == 0: self.value = in_literal() elif rnd == 1: self.value = inout_literal() elif rnd == 2: self.value = out_literal() elif rnd == 3: self.value = empty_literal() self.value.randomize()
def generate_random_externs(self): rnd = randomizer.randint(self.min_random_externs, self.max_random_externs) extern_declarations = [] for x in range(0, rnd): _extern_declaration = extern_declaration() _extern_declaration.randomize() extern_declarations.append(_extern_declaration) code = "" for _extern_declaration in extern_declarations: code += _extern_declaration.generate_code() return code
def randomize(self): common.usedRandomize() self.type = randomizer.getRandom(self.probabilities) if self.type == 0: self.opt_annotations = opt_annotations() self.opt_annotations.randomize() available_actions = scope.get_available_actions() rnd_action = randomizer.randint(0, len(available_actions) - 1) if self.force_action is not None: rnd_action = self.force_action self.name = available_actions.keys()[rnd_action] else: self.opt_annotations = opt_annotations() self.opt_annotations.randomize() available_actions = scope.get_available_actions() rnd_action = randomizer.randint(0, len(available_actions) - 1) if self.force_action is not None: rnd_action = self.force_action self.name = available_actions.keys()[rnd_action] self.argument_list = argument_list() self.argument_list.randomize()
def generate_random_parsers(self): rnd = randomizer.randint(self.min_random_parsers, self.max_random_parsers) parser_declarations = [] for x in range(0, rnd): _parser_declaration = parser_declaration() _parser_declaration.randomize() parser_declarations.append(_parser_declaration) code = "" for _parser_declaration in parser_declarations: code += _parser_declaration.generate_code() return code
def generate_random_headers(self): rnd = randomizer.randint(self.min_random_headers, self.max_random_headers) header_type_declarations = [] for x in range(0, rnd): _header_type_declaration = header_type_declaration() _header_type_declaration.randomize() header_type_declarations.append(_header_type_declaration) code = "" for _header_type_declaration in header_type_declarations: code += _header_type_declaration.generate_code() return code
def generate_random_structs(self): rnd = randomizer.randint(self.min_random_structs, self.max_random_structs) struct_type_declarations = [] for x in range(0, rnd): _struct_type_declaration = struct_type_declaration() _struct_type_declaration.randomize() struct_type_declarations.append(_struct_type_declaration) code = "" for _struct_type_declaration in struct_type_declarations: code += _struct_type_declaration.generate_code() return code
def generate_random_controls(self): rnd = randomizer.randint(self.min_random_controls, self.max_random_controls) control_declarations = [] for x in range(0, rnd): _control_declaration = control_declaration() _control_declaration.randomize() control_declarations.append(_control_declaration) code = "" for _control_declaration in control_declarations: code += _control_declaration.generate_code() + '\n\n' return code
def generate_extern_variables(self): rnd = randomizer.randint(self.min_extern_variables, self.max_extern_variables) extern_variables = [] for x in range(0, rnd): _extern_variable = extern_variable_creation() _extern_variable.randomize() extern_variables.append(_extern_variable) code = "" for _extern_variable in extern_variables: code += _extern_variable.generate_code() return code
def randomize(self): while True: self.type = randomizer.getRandom(self.probabilities) if self.type == 0: available_states = scope.get_available_states() self.value = available_states.keys()[randomizer.randint( 0, len(available_states) - 1)] elif self.type == 1: self.value = select_expression() self.value.randomize() if not self.filter(): break
def randomize(self): rnd = randomizer.randint(0, 4) if rnd == 0: self.value = constant_declaration() elif rnd == 1: self.value = action_declaration() elif rnd == 2: self.value = table_declaration() elif rnd == 3: self.value = instantiation() elif rnd == 4: self.value = variable_declaration() self.value.randomize()