Esempio n. 1
0
def action_check_connections(args, test_step, expected, params_list):
  """ Check that the current state the controller reads from the endpoints matches
      the state the test framework expects.
  """
  checks = []

  # Expect all connections to be restored
  for c,n in state.get_current().active_connections.iteritems():
    if n:
      if args.controller_type == 'python':
        checks += [Expected(args.controller_id, "0x%s\[%d\] -> 0x%s\[%d\]" % (
                        endpoints.guid_in_ascii(args.user, endpoints.get(c.talker.src)),
                        c.talker.src_stream,
                        endpoints.guid_in_ascii(args.user, endpoints.get(c.listener.dst)),
                        c.listener.dst_stream), 10)]
      else:
        checks += [Expected(args.controller_id, "0x%s\[%d\] -> 0x%s\[%d\]" % (
                        endpoints.guid_in_ascii(args.user, endpoints.get(c.talker.src)).zfill(16),
                        c.talker.src_stream,
                        endpoints.guid_in_ascii(args.user, endpoints.get(c.listener.dst)).zfill(16),
                        c.listener.dst_stream), 10)]

  print_title("Command: show_connections")
  args.master.sendLine(args.controller_id, "show connections")

  if test_step.do_checks:
    if checks:
      expected += [AllOf(checks)]
    elif test_step.checkpoint is None:
      expected += [NoneOf([Expected(args.controller_id, "->", 5)])]

  yield args.master.expect(None)
Esempio n. 2
0
def action_ping(args, test_step, expected, params_list):
  """ Ping a node with and check that it responds accordingly. This is used to test
      connectivity.
  """
  ep_name = choose_src(params_list, 0)
  ep = endpoints.get(ep_name)

  node_expect = [Expected(ep_name, "IDENTIFY Ping", 5)]

  if args.controller_type == 'python':
    controller_expect = [Expected(args.controller_id, "Success", 5)]

    print_title("Command: identify %s on" % ep_name)
    args.master.sendLine(args.controller_id, "identify 0x%s on" % endpoints.guid_in_ascii(args.user, ep))
    print_title("Command: identify %s off" % ep_name)
    args.master.sendLine(args.controller_id, "identify 0x%s off" % endpoints.guid_in_ascii(args.user, ep))
  else:
    controller_expect = [Expected(args.controller_id, "NOTIFICATION.*SET_CONTROL.*SUCCESS", 10, consumeOnMatch=True)]

    print_title("Command: identify on %s" % ep_name)
    args.master.sendLine(args.controller_id, "identify on 0x%s" % endpoints.guid_in_ascii(args.user, ep))
    print_title("Command: identify off %s" % ep_name)
    args.master.sendLine(args.controller_id, "identify off 0x%s" % endpoints.guid_in_ascii(args.user, ep))

  if test_step.do_checks and (node_expect or controller_expect):
    expected += [AllOf(node_expect + controller_expect)]

  yield args.master.expect(None)
Esempio n. 3
0
def controller_connect(args, test_step, expected, src, src_stream, dst, dst_stream):
  talker_ep = endpoints.get(src)
  listener_ep = endpoints.get(dst)

  state.get_next().connect(src, src_stream, dst, dst_stream)
  check_set_clock_masters(args, test_step, expected)

  args.master.sendLine(args.controller_id, "connect 0x%s %d 0x%s %d" % (
        endpoints.guid_in_ascii(args.user, talker_ep), src_stream,
        endpoints.guid_in_ascii(args.user, listener_ep), dst_stream))
Esempio n. 4
0
def controller_disconnect(args, test_step, expected, src, src_stream, dst, dst_stream):
  talker_ep = endpoints.get(src)
  listener_ep = endpoints.get(dst)

  state.get_next().disconnect(src, src_stream, dst, dst_stream)
  check_clear_clock_masters(args, test_step, expected)

  print_title("Command: disconnect %s %d %s %d" % (src, src_stream, dst, dst_stream))
  args.master.sendLine(args.controller_id, "disconnect 0x%s %d 0x%s %d" % (
        endpoints.guid_in_ascii(args.user, talker_ep), src_stream,
        endpoints.guid_in_ascii(args.user, listener_ep), dst_stream))
Esempio n. 5
0
def analyzer_qav_seq(test_step, src, dst, action, user):
  """ Get the expected sequence for any QAV analyzers active.
  """
  analyzer_expect = []

  for analyzer_name,analyzer in analyzers.get_all().iteritems():
    if analyzer['type'] != 'qav':
      continue

    # If the analyzer is a QAV analyzer then it will detect the stream through
    # the packets being forwarded through it
    if analyzer_name in graph.find_path(state.get_current(), src, dst):
      guid_string = endpoints.guid_in_ascii(user, endpoints.get(src))
      stream_string = endpoints.stream_from_guid(guid_string)
      if action == 'connect':
        action_string = "Adding"
        completionFn = hook_register_error
      else:
        action_string = "Removing"
        completionFn = hook_unregister_error

      analyzer_expect += [Expected(analyzer_name, "%s stream 0x%s" % (action_string, stream_string),
            timeoutTime=10,
            completionFn=completionFn,
            completionArgs=(analyzer_name, ['ERROR']))]

  return analyzer_expect
Esempio n. 6
0
def check_set_clock_masters(args, test_step, expected):
  for loop in graph.get_loops(state.get_next()):
    loop_master = loop[0]
    for ep_name in loop:
      # Look at the next state in case the node has just been set clock master
      if state.get_next().is_clock_source_master(ep_name):
        loop_master = ep_name
        break

    if not state.get_next().is_clock_source_master(loop_master):
      ep = endpoints.get(loop_master)
      print_title("Command: set_clock_source_master %s" % loop_master)
      if args.controller_type == 'python':
        args.master.sendLine(args.controller_id, "set_clock_source_master 0x%s" % (
              endpoints.guid_in_ascii(args.user, ep)))
      else:
        select_endpoint(args, ep)
        args.master.sendLine(args.controller_id, "set clock_source 0 0 1")

      state.get_next().set_clock_source_master(ep['name'])

      if test_step.do_checks:
        controller_expect = sequences.expected_seq('controller_success_set_clock_source')(args, test_step)
        ep_expect = [Expected(loop_master, "Setting clock source: LOCAL_CLOCK", 5)]
        if controller_expect or ep_expect:
          expected += [AllOf(controller_expect + ep_expect)]
Esempio n. 7
0
def action_ping(args, test_step, expected, params_list):
  """ Ping a node with and check that it responds accordingly. This is used to test
      connectivity.
  """
  ep_name = choose_src(params_list, 0)
  ep = endpoints.get(ep_name)

  node_expect = [Expected(ep_name, "IDENTIFY Ping", 5)]
  controller_expect = [Expected(args.controller_id, "Success", 5)]

  args.master.sendLine(args.controller_id, "identify 0x%s on" % endpoints.guid_in_ascii(args.user, ep))
  args.master.sendLine(args.controller_id, "identify 0x%s off" % endpoints.guid_in_ascii(args.user, ep))

  if test_step.do_checks and (node_expect or controller_expect):
    expected += [AllOf(node_expect + controller_expect)]

  yield args.master.expect(None)
Esempio n. 8
0
def talker_existing_connect_seq(test_step, user, src, src_stream, dst, dst_stream):
  stream_id = endpoints.stream_from_guid(endpoints.guid_in_ascii(user, endpoints.get(src)))
  listener_mac = endpoints.mac_in_ascii(user, endpoints.get(dst))
  talker_connection = [
        Sequence([Expected(src, "CONNECTING Talker stream #%d \(%s\) -> Listener %s" %
                    (src_stream, stream_id, listener_mac), 10)])
    ]
  return talker_connection
Esempio n. 9
0
def check_clear_clock_masters(args, test_step, expected):
  for name,ep in endpoints.get_all().iteritems():
    if state.get_current().is_clock_source_master(name) and not graph.is_in_loop(state.get_current(), ep['name']):
      args.master.sendLine(args.controller_id, "set_clock_source_slave 0x%s" % (
            endpoints.guid_in_ascii(args.user, ep)))
      state.get_next().set_clock_source_slave(ep['name'])

      if test_step.do_checks:
        controller_expect = [Expected(args.controller_id, "Success", 5)]
        ep_expect = [Expected(ep['name'], "Setting clock source: INPUT_STREAM_DERIVED", 5)]
        if controller_expect or ep_expect:
          expected += [AllOf(controller_expect + ep_expect)]
Esempio n. 10
0
def talker_new_connect_seq(test_step, user, src, src_stream, dst, dst_stream):
  """ Only on the first time the talker is turned on must the 'ready' be seen.
  """
  stream_id = endpoints.stream_from_guid(endpoints.guid_in_ascii(user, endpoints.get(src)))
  listener_mac = endpoints.mac_in_ascii(user, endpoints.get(dst))
  seq = [Expected(src, "CONNECTING Talker stream #%d \(%s\) -> Listener %s" %
            (src_stream, stream_id, listener_mac), 10)]
  if not state.get_current().get_talker_on_count(src):
    seq += [Expected(src, "Talker stream #%d ready" % src_stream, 10)]
  seq += [Expected(src, "Talker stream #%d on" % src_stream, 10)]

  talker_connection = [Sequence(seq)]
  return talker_connection
Esempio n. 11
0
def controller_enumerate(args, avb_ep):
  entity_id = endpoints.get(avb_ep)
  print_title("Command: enumerate %s" % avb_ep)
  if args.controller_type == 'python':
    args.master.sendLine(args.controller_id, "enumerate 0x%s" % (
          endpoints.guid_in_ascii(args.user, entity_id)))
  else:
    select_endpoint(args, entity_id)

    descriptors = endpoints.get(avb_ep)['descriptors']
    for dtor in sorted(descriptors.keys()):
      index = 0
      command = "view descriptor %s %d" % (re.sub('\d*_', '', dtor, 1), index)
      args.master.sendLine(args.controller_id, command.encode('ascii', 'ignore'))
Esempio n. 12
0
def check_clear_clock_masters(args, test_step, expected):
  for name,ep in endpoints.get_all().iteritems():
    if state.get_current().is_clock_source_master(name) and not graph.is_in_loop(state.get_current(), ep['name']):
      print_title("Command: set_clock_source_slave %s" % name)
      if args.controller_type == 'python':
        args.master.sendLine(args.controller_id, "set_clock_source_slave 0x%s" % (
              endpoints.guid_in_ascii(args.user, ep)))
      else:
        select_endpoint(args, ep)
        args.master.sendLine(args.controller_id, "set clock_source 0 0 0")

      state.get_next().set_clock_source_slave(ep['name'])

      if test_step.do_checks:
        controller_expect = sequences.expected_seq('controller_success_set_clock_source')(args, test_step)
        ep_expect = [Expected(ep['name'], "Setting clock source: INPUT_STREAM_DERIVED", 5)]
        if controller_expect or ep_expect:
          expected += [AllOf(controller_expect + ep_expect)]
Esempio n. 13
0
def talker_new_connect_seq(test_step, user, src, src_stream, dst, dst_stream):
  """ Only on the first time the talker is turned on must the 'ready' be seen.
  """
  stream_id = endpoints.stream_from_guid(endpoints.guid_in_ascii(user, endpoints.get(src)))
  listener_mac = endpoints.mac_in_ascii(user, endpoints.get(dst))
  seq = [Expected(src, "CONNECTING Talker stream #%d \(%s\) -> Listener %s" %
            (src_stream, stream_id, listener_mac), 10)]
  if not state.get_current().get_talker_on_count(src):
    seq += [Expected(src, "Talker stream #%d ready" % src_stream, 10)]
  seq += [Expected(src, "Talker stream #%d on" % src_stream, 10)]

  # If in a sequence of commands then the order cannot be guaranteed - so only
  # expect a Sequence when not checkpointing
  if test_step.checkpoint is None:
    talker_connection = [Sequence(seq)]
  else:
    talker_connection = [AllOf(seq)]
  return talker_connection
Esempio n. 14
0
def check_set_clock_masters(args, test_step, expected):
  for loop in graph.get_loops(state.get_current()):
    loop_master = loop[0]
    for ep_name in loop:
      if state.get_current().is_clock_source_master(ep_name):
        loop_master = ep_name
        break

    if not state.get_current().is_clock_source_master(loop_master):
      ep = endpoints.get(loop_master)
      args.master.sendLine(args.controller_id, "set_clock_source_master 0x%s" % (
            endpoints.guid_in_ascii(args.user, ep)))
      state.get_next().set_clock_source_master(ep['name'])

      if test_step.do_checks:
        controller_expect = [Expected(args.controller_id, "Success", 5)]
        ep_expect = [Expected(loop_master, "Setting clock source: LOCAL_CLOCK", 5)]
        if controller_expect or ep_expect:
          expected += [AllOf(controller_expect + ep_expect)]
Esempio n. 15
0
def controller_enumerate(args, avb_ep):
  entity_id = endpoints.get(avb_ep)
  args.master.sendLine(args.controller_id, "enumerate 0x%s" % (
        endpoints.guid_in_ascii(args.user, entity_id)))
Esempio n. 16
0
def select_endpoint(args, endpoint_name):
  entity = 0
  configuration = 0
  args.master.sendLine(args.controller_id, "select 0x%s %d %d" % (
        endpoints.guid_in_ascii(args.user, endpoint_name), entity, configuration))