예제 #1
0
def action_discover(args, test_step, expected, params_list):
  if args.controller_type == 'c':
    # Can take up to 20 seconds to timeout entities which have disappeared
    yield base.sleep(20)

    print_title("Command: list")
    args.master.sendLine(args.controller_id, "list")

    yield base.sleep(2)

  else:
    args.master.clearExpectHistory(args.controller_id)
    print_title("Command: discover")
    args.master.sendLine(args.controller_id, "discover")

    yield args.master.expect(Expected(args.controller_id, "Found \d+ entities", 15))

  # Actually check that the right number of entities have been seen
  visible_endpoints = graph.get_endpoints_connected_to(state.get_current(), args.controller_id)
  controller = getActiveProcesses()[args.controller_id]
  if len(controller.entities) != len(visible_endpoints):
    base.testError("Found %d entities, expecting %d" % (len(controller.entities), len(visible_endpoints)), critical=True)
  else:
    log_info("Found %d entities" % len(controller.entities))

  yield args.master.expect(None)
예제 #2
0
  def get_controller_state(self, controller_id, src, src_stream, dst, dst_stream, action):
    controllable_endpoints = graph.get_endpoints_connected_to(self, controller_id)
    if src not in controllable_endpoints or dst not in controllable_endpoints:
      state = 'timeout'

    elif action == 'connect':
      if src == dst:
        if self.listener_active_count(dst, dst_stream):
          state = 'listener_exclusive'
        else:
          state = 'listener_talker_timeout'
      elif self.connected(src, src_stream, dst, dst_stream):
        state = 'success'
      elif self.listener_active_count(dst, dst_stream):
        state = 'listener_exclusive'
      else:
        state = 'success'

    elif action == 'disconnect':
      if not self.connected(src, src_stream, dst, dst_stream):
        state = 'redundant'
      else:
        state = 'success'

    else:
      base.testError("Unknown action '%s'" % action, critical=True)

    log_debug("get_controller_state for %s %d %s %d: %s" % (src, src_stream, dst, dst_stream, state))
    return ('controller_' + state + '_' + action)
예제 #3
0
def action_discover(args, test_step, expected, params_list):
  args.master.clearExpectHistory(args.controller_id)
  args.master.sendLine(args.controller_id, "discover")
  visible_endpoints = graph.get_endpoints_connected_to(state.get_current(), args.controller_id)

  if test_step.do_checks:
    expected += [Expected(args.controller_id, "Found %d entities" % len(visible_endpoints), 15)]

  yield args.master.expect(None)
예제 #4
0
def controller_enumerate_seq(args, test_step, endpoint_name):
    """ Build an enumerated sequence for an entity by reading from a topology file
    """
    expected_seq = []
    descriptors = endpoints.get(endpoint_name)['descriptors']

    if args.controller_type == 'python':
      # The python controller reads the descriptors each time. The C controller has
      # them cached and so can always return the values.
      visible_endpoints = graph.get_endpoints_connected_to(state.get_current(), args.controller_id)
      if endpoint_name not in visible_endpoints:
        return [Expected(args.controller_id, "No descriptors found", 10, consumeOnMatch=True)]

      for dtor in sorted(descriptors.keys()):
        # Note that the .* is required because the STREAM_INPUT/STREAM_OUTPUT are mapped to the same descriptor
        temp_string = "AVB 1722\.1.*%s" % re.sub('\d*_', '', dtor, 1)
        expected_seq.append(Expected(args.controller_id, temp_string, 10, consumeOnMatch=True))
        for dtor_name in descriptors[str(dtor)].keys():
          temp_string = "object_name\s*=\s*\'%s\'" % dtor_name
          expected_seq.append(Expected(args.controller_id, temp_string, 10, consumeOnMatch=True))
          for element in descriptors[str(dtor)][dtor_name]:
            element_type = element.get('type', 'none')
            if element_type == 'hex':
              temp_string = "%s\s*=\s*0x%x" % (element['item'], element['value'])
            elif element_type == 'state':
              value = eval('state.get_current().get_%s' % element['item'])(endpoint_name)
              temp_string = "%s\s*=\s*%s" % (element['item'], value)
            else:
              temp_string = "%s\s*=\s*%s" % (element['item'], element['value'])
            expected_seq.append(Expected(args.controller_id, temp_string, 10, consumeOnMatch=True))

    else:
      for dtor in sorted(descriptors.keys()):
        temp_string = "descriptor_type: %s" % re.sub('\d*_', '', dtor, 1)
        expected_seq.append(Expected(args.controller_id, temp_string, 10, consumeOnMatch=True))
        for dtor_name in descriptors[str(dtor)].keys():
          temp_string = "object_name\s*=\s*%s" % dtor_name
          expected_seq.append(Expected(args.controller_id, temp_string, 10, consumeOnMatch=True))
          for element in descriptors[str(dtor)][dtor_name]:
            element_type = element.get('type', 'none')
            if element_type == 'flag':
              temp_string = "%s\s*=\s*1" % element['value'].lower()
            elif element_type == 'state':
              value = eval('state.get_current().get_%s' % element['item'])(endpoint_name)
              temp_string = "%s\s*=\s*%s" % (element['item'], value)
            else:
              temp_string = "%s\s*=\s*%s" % (element['item'], element['value'])
            expected_seq.append(Expected(args.controller_id, temp_string, 10, consumeOnMatch=True))

    return [Sequence(expected_seq)]
예제 #5
0
def controller_enumerate_seq(test_step, controller_id, endpoint_name):
    """ Build an enumerated sequence for an entity by reading from a topology file
    """
    expected_seq = []

    visible_endpoints = graph.get_endpoints_connected_to(state.get_current(), controller_id)
    if endpoint_name not in visible_endpoints:
      return [Expected(controller_id, "No descriptors found", 10)]

    descriptors = endpoints.get(endpoint_name)['descriptors']
    for dtor in sorted(descriptors.keys()):
        temp_string = "AVB 1722.1 {0} ".format(re.sub('\d*_', '', dtor, 1))
        expected_seq.append(Expected(controller_id, temp_string, 10))
        for dtor_name in descriptors[str(dtor)].keys():
            temp_string = "object_name\s*=\s*\'{0}\'".format(dtor_name)
            expected_seq.append(Expected(controller_id, temp_string, 10))
            for element in descriptors[str(dtor)][dtor_name]:
                temp_string = "{0}\s*=\s*{1}".format(element['item'], element['value'])
                expected_seq.append(Expected(controller_id, temp_string, 10))

    return [Sequence(expected_seq)]