예제 #1
0
def action_link_down(args, test_step, expected, params_list):
  analyzer_name = choose_analyzer(params_list, 0)

  checks = []
  affected_talkers = set()
  # Expect all the connections which cross the relay to be lost
  for c,n in state.get_current().active_connections.iteritems():
    if not n:
      continue

    path = graph.find_path(state.get_current(), c.talker.src, c.listener.dst)
    if path and analyzer_name in path:
      affected_talkers |= set([c.talker])
      checks += [Expected(c.listener.dst, "ADP: Removing entity who timed out -> GUID", 30)]
      checks += sequences.analyzer_listener_disconnect_seq(test_step,
                      c.talker.src, c.talker.src_stream,
                      c.listener.dst, c.listener.dst_stream)
      state.get_next().disconnect(c.talker.src, c.talker.src_stream, c.listener.dst, c.listener.dst_stream)

  for talker in affected_talkers:
    if not state.get_next().talker_active_count(talker.src, talker.src_stream):
      checks += [Expected(talker.src, "Talker stream #%d off" % talker.src_stream, 30)]

  # Send the command to close the relay '(r)elay (c)lose'
  args.master.sendLine(analyzer_name, "r o")
  state.get_next().set_relay_open(analyzer_name)

  if test_step.do_checks and checks:
    expected += [AllOf(checks)]
    yield args.master.expect(None)
  else:
    # At least allow time for the relay to actually be closed
    yield base.sleep(0.1)
예제 #2
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)]
예제 #3
0
def action_link_up(args, test_step, expected, params_list):
  analyzer_name = choose_analyzer(params_list, 0)

  # Send the command to close the relay '(r)elay (c)lose'
  args.master.sendLine(analyzer_name, "r c")
  state.get_next().set_relay_closed(analyzer_name)

  # Always allow time for the relay to actually be opened
  yield base.sleep(0.1)
예제 #4
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))
예제 #5
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))
예제 #6
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)]
예제 #7
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)]
예제 #8
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)]
예제 #9
0
def action_link_downup(args, test_step, expected, params_list):
  """ Expect all connections which bridge the relay to be lost and restored if there
      is a quick link down/up event. The first argument is the analyzer controlling
      the relay. The second is the time to sleep before restoring the link.
  """
  analyzer_name = choose_analyzer(params_list, 0)
  sleep_time = int(params_list[1])

  lost = []
  # Expect all the connections which cross the relay to be lost
  for c,n in state.get_current().active_connections.iteritems():
    if n and analyzer_name in graph.find_path(state.get_current(), c.talker.src, c.listener.dst):
      lost += sequences.analyzer_listener_disconnect_seq(test_step,
                      c.talker.src, c.talker.src_stream,
                      c.listener.dst, c.listener.dst_stream)

  # Send the command to open the relay '(r)elay (o)pen'
  args.master.sendLine(analyzer_name, "r o")
  state.get_next().set_relay_open(analyzer_name)

  if test_step.do_checks and lost:
    expected += [AllOf(lost)]

  # Perform a sleep as defined by the second argument
  yield base.sleep(sleep_time)

  found = []
  # Expect all the connections which cross the relay to be restored
  state.get_next().set_relay_closed(analyzer_name)
  for c,n in state.get_current().active_connections.iteritems():
    if n and analyzer_name in graph.find_path(state.get_current(), c.talker.src, c.listener.dst):
      found += sequences.analyzer_listener_connect_seq(test_step,
                      c.talker.src, c.talker.src_stream,
                      c.listener.dst, c.listener.dst_stream)

  # Send the command to close the relay '(r)elay (c)lose'
  args.master.sendLine(analyzer_name, "r c")

  if test_step.do_checks and found:
    expected += [AllOf(found)]

  yield args.master.expect(None)
예제 #10
0
def search(n):
    s = state.create(n)
    # print(s)
    f = frontier.create(s)
    while not frontier.is_empty(f):
        s = frontier.remove(f)
        if state.is_target(s):
            return [s, f[1], f[4]]
        ns = state.get_next(s)
        for i in ns:
            frontier.insert(f, i)
    return 0
예제 #11
0
def search(n):  # searches for the target state of the game
    s = state.create(n)  # creates a new random board
    print(s)
    f = frontier.create(s)  # returns a priority queue that contains s
    while not frontier.is_empty(f):  # while the queue isn't empty
        s = frontier.remove(f)  # getting the first state out of the queue
        if state.is_target(s):  # if this state is the target
            return s  # , numStates, maxStates  # returns the target, the number of states we've done do far
            # and the max. number of states that have been together at the same time
        ns = state.get_next(s)  # saving the sons of this state we're at
        for i in ns:  # running trough the sons to check them too
            frontier.insert(f, i)  # inserts the sons into the frontier- queue
    return 0  # when done
예제 #12
0
def search(n):
    cost = 0
    s = state.create(n)
    f = frontier.create(s)
    while not frontier.is_empty(f):
        s = frontier.remove(f)
        if state.is_target(s):
            return [s, f[1], cost]
        ns = state.get_next(s)
        for i in ns:
            frontier.insert(f, i)
            cost += 1
    return [0, 0, cost]
예제 #13
0
def search(n):
    trys = 0
    f = PQueue(state.create(n))
    # f = frontier1.create(state.create(n))
    while not (f.is_empty()):
        s = f.remove()
        # print (s)
        if state.is_target(s):
            return [s, f.returnTotalStates(), f.returnMaxStates()]
        else:
            trys += 1
        ns = state.get_next(s)
        for i in range(0, len(ns)):
            f.insert(ns[i])
    return None
예제 #14
0
파일: search.py 프로젝트: sibendav/IDSearch
def search(n):
    num = 1
    maxi = 0
    s = state.create(n)
    print(s)
    f = frontier.create(s)
    while not frontier.is_empty(f):
        s = frontier.remove(f)
        if state.is_target(s):
            return s
        ns = state.get_next(s)
        num += len(ns)
        for i in ns:
            frontier.insert(f, i)
        if maxi < len(ns):
            maxi = len(ns)

    return 0
예제 #15
0
def port_shaper_change_seq(test_step, ep, port, action):
    expected = graph.calculate_expected_bandwidth(state.get_next(), ep, port)
    return [ Expected(ep['name'], "%s port %d shaper bandwidth to %s" % (action, port, expected), 10) ]