def action_disconnect(args, test_step, expected, params_list): src = choose_src(params_list, 0) src_stream = choose_src_stream(params_list, 1) dst = choose_dst(params_list, 2) dst_stream = choose_dst_stream(params_list, 3) controller_disconnect(args, test_step, expected, src, dst_stream, dst, dst_stream) (talker_expect, listener_expect, controller_expect) = get_expected( args, test_step, src, src_stream, dst, dst_stream, 'disconnect') # Find the path between the src and dst and check whether there are any nodes between them forward_disable = [] nodes = endpoints.get_path_endpoints(graph.find_path(state.get_current(), src, dst)) for node in get_dual_port_nodes(nodes): if graph.node_will_see_stream_disable(state.get_current(), src, src_stream, dst, dst_stream, node): forward_disable += sequences.expected_seq('stream_forward_disable')(test_step, args.user, endpoints.get(node), endpoints.get(src)) forward_disable += sequences.expected_seq('port_shaper_disconnect')(test_step, endpoints.get(node), src, src_stream, dst, dst_stream) # If there are any nodes in the chain then the forward disabling is expected before the # audio will be seen to be lost if forward_disable and listener_expect: listener_expect = [Sequence([AllOf(forward_disable)] + listener_expect)] elif forward_disable: listener_expect = forward_disable elif listener_expect: listener_expect = listener_expect else: listener_expect = [] # Expect not to see any disables from other nodes not_forward_disable = [] temp_nodes = set(endpoints.get_all().keys()) - set(nodes) for node in get_dual_port_nodes(temp_nodes): not_forward_disable += sequences.expected_seq('stream_forward_disable')(test_step, args.user, endpoints.get(node), endpoints.get(src)) if not_forward_disable: if test_step.checkpoint is None: not_forward_disable = [NoneOf(not_forward_disable)] else: not_forward_disable = [] for node in get_dual_port_nodes(temp_nodes): not_forward_disable += sequences.expected_seq('port_shaper_disconnect')(test_step, endpoints.get(node), src, src_stream, dst, dst_stream) if test_step.checkpoint: final_port_shaper_states = sequences.get_and_clear_final_port_shaper_states() else: final_port_shaper_states = [] if test_step.do_checks and (talker_expect or listener_expect or controller_expect or not_forward_disable or final_port_shaper_states): expected += [AllOf(talker_expect + listener_expect + controller_expect + not_forward_disable + final_port_shaper_states)] yield args.master.expect(None)
def get_endpoints_connected_to(state, node): connected = set() for endpoint in endpoints.get_all(): if find_path(state, node, endpoint): connected |= set([endpoint]) log_debug("get_endpoints_connected_to %s: %s" % (node, connected)) return connected
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)]
def check_endpoint_startup(): """ Ensure that the endpoints have started correctly. The exact sequence will depend on which endpoint is the grandmaster. """ grandmaster = endpoints.determine_grandmaster(args.user) log_info("Using grandmaster {gm_id}".format(gm_id=endpoints.get_avb_id(args.user, grandmaster))) # Check that all endpoints go to PTP master in 30 seconds and then one of the # ports will go Master or Slave and lock ptp_startup = [AllOf( [ptp_startup_two_port(e, grandmaster, args.user) for e in filter(lambda x: x['ports'] == 2, endpoints.get_all().values())] + [ptp_startup_single_port(e, grandmaster, args.user) for e in filter(lambda x: x['ports'] == 1, endpoints.get_all().values())] )] maap = [ AllOf([Expected(e['name'], 'MAAP reserved Talker stream #%d address: 91:E0:F0:0' % n, 40) for n in range(e['talker_streams'])]) for e in endpoints.get_all().values() ] yield master.expect(AllOf(ptp_startup + maap))
def dump(self): log_debug("State:") for t,n in self.active_talkers.iteritems(): log_debug("Talker %s : %d" % (t, n)) for l,n in self.active_listeners.iteritems(): log_debug("Listeners %s : %d" % (l, n)) for c,n in self.active_connections.iteritems(): log_debug("Connection %s : %d" % (c, n)) for c,n in self.talker_on_count.iteritems(): log_debug("Talker on count %s : %d" % (c, n)) for c,n in self.clock_source_master.iteritems(): if n: log_debug("Clock source master %s" % c) rendering.draw_state(self, sorted(endpoints.get_all().keys()))
def ptp_startup_two_port(e, grandmaster, user): """ Determine the PTP sequence for the node. If it is not the grandmaster it should go to slave and lock """ slave_seq = [] if grandmaster and (endpoints.get_avb_id(user, e) != endpoints.get_avb_id(user, grandmaster)): # The length of time to sync will depend on the total number of endpoints sync_lock_time = 3 * len(endpoints.get_all()) slave_seq = [Sequence( [Expected(e['name'], 'PTP Port \d+ Role: Slave', 40), Expected(e['name'], 'PTP sync locked', sync_lock_time)])] return Sequence( [Expected(e['name'], 'PTP Port 0 Role: Master', 40), Expected(e['name'], 'PTP Port 1 Role: Master', 5)] + slave_seq)
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)]