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)
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)
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)
def runTest(args): """ The test program - needs to yield on each expect and be decorated with @inlineCallbacks """ for y in configure_generators(): yield y for y in configure_analyzers(): yield y for y in check_endpoint_startup(): yield y expected = [] for y in action_discover(args, generator.Command("discover"), expected, []): yield y for e in expected: yield args.master.expect(e) expected = [] if not getEntities(): base.testError("no entities found", critical=True) test_num = 1 check_num = 1 for test_step in test_steps: state.move_next_to_current() command = test_step.command print_title("Command %d: %s" % (test_num, command)) test_num += 1 action = command.split(' ') action_function = eval('action_%s' % action[0]) for y in action_function(args, test_step, expected, action[1:]): yield y if test_step.checkpoint or test_step.checkpoint is None: print_title("Check: %d" % check_num) check_num += 1 if expected: yield args.master.expect(AllOf(expected)) expected = [] # Ensure that any remaining output of a previous test step is flushed for process in getActiveProcesses(): master.clearExpectHistory(process) # Allow everything time to settle (in case an error is being generated) yield base.sleep(5) base.testComplete(reactor)
def runTest(args): """ The test program - needs to yield on each expect and be decorated with @inlineCallbacks """ for y in configure_generators(): yield y for y in configure_analyzers(): yield y for y in check_endpoint_startup(): yield y expected = [] for y in action_discover(args, generator.Command("discover"), expected, []): yield y check_num = 1 for test_step in test_steps: print_comment(test_step) state.move_next_to_current() command = test_step.get_command() if command is None: continue action = command.split(' ') action_function = eval('action_%s' % action[0]) expected = [] for y in action_function(args, test_step, expected, action[1:]): yield y if expected: args.master.addExpected(AllOf(expected)) if (test_step.checkpoint or test_step.checkpoint is None) and args.master.nextExpected: print_title("Check: %d" % check_num) check_num += 1 args.master.startNext() yield args.master.expect() # Ensure that any remaining output of a previous test step is flushed for process in getActiveProcesses(): master.clearExpectHistory(process) # Allow everything time to settle (in case an error is being generated) yield base.sleep(5) base.testComplete(reactor)
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)
def action_sleep(args, test_step, expected, params_list): """ Do nothing for the defined time. """ yield base.sleep(int(params_list[0]))
def runTest(args): master = xmos.test.master.Master() analysis_bin = os.path.join(rootDir, 'sw_audio_analyzer', 'app_audio_analyzer_avb', 'bin', 'audio_analyzer.xe') xrun = xrunProcess(master, args.adapter_id, "xrun", analysis_bin) controller_path = os.path.join(rootDir, 'sw_audio_analyzer', 'host_audio_analyzer') controller_id = 'controller' controller = process.Process(controller_id, master, output_file="controller.log", verbose=True) reactor.spawnProcess(controller, './audio_analyzer', ['./audio_analyzer'], env=os.environ, path=controller_path) # Wait for the controller to have started yield master.expect(Expected(controller_id, "^Starting I2S$", 10)) # Allow time for everything to settle yield base.sleep(5) master.sendLine(controller_id, "d a") yield master.expect(Expected(controller_id, "Channel 0: disabled", 15)) # There needs to be small delays to allow the audio signals to settle, otherwise # spurious glitches are detected. delay = 0.5 test_frequencies = [1000, 2000, 4000, 8000] # Ensure that there is no glitch by default for freq in test_frequencies: master.sendLine(controller_id, "d 0") yield master.expect(Expected(controller_id, "Channel 0: disabled", 15)) yield base.sleep(delay) master.sendLine(controller_id, "c 0 {freq}".format(freq=freq)) yield master.expect(Expected(controller_id, "Generating sine table for chan 0", 15)) yield base.sleep(delay) master.sendLine(controller_id, "e 0") yield master.expect(Sequence([ Expected(controller_id, "Channel 0: enabled", 5), Expected(controller_id, "Channel 0: Signal detected", 10), Expected(controller_id, "Channel 0: Frequency %d" % freq, 5)])) yield master.expect(NoneOf([Expected(controller_id, "ERROR: Channel 0: glitch detected", 30)])) offset = 5000 for freq in test_frequencies: log_info("-----------------") log_info("Test %d Hz" % freq) num_points = int(48000/freq); for period in range(0, num_points): log_info("Test for glitch at %d (%d/%d)" % (freq, period + 1, num_points)) # Disable all channels master.sendLine(controller_id, "d 0") yield master.expect(Expected(controller_id, "Channel 0: disabled", 15)) yield base.sleep(delay) master.sendLine(controller_id, "c 0 {freq} -1 0 {period}".format(freq=freq, period=period+offset)) yield master.expect(Expected(controller_id, "Generating sine table for chan 0", 15)) yield base.sleep(delay) master.sendLine(controller_id, "e 0") yield master.expect(Sequence([ Expected(controller_id, "Channel 0: enabled", 5), Expected(controller_id, "Channel 0: Signal detected", 10), Expected(controller_id, "Channel 0: Frequency %d" % freq, 5)])) yield master.expect(Expected(controller_id, "ERROR: Channel 0: glitch detected", 15)) yield base.sleep(delay) base.testComplete(reactor)