Beispiel #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)
Beispiel #2
0
def startXrun(combined_args):
  (name, process, adapter_id, bin, args) = combined_args

  # Windows requires the absolute path of xrun
  exe_name = base.exe_name('xrun')
  xrun = base.file_abspath(exe_name)

  log_info("Starting %s (%s)" % (name, ' '.join(['--adapter-id', adapter_id, '--xscope', '--xscope-file',  name + '.xmt', bin])))
  reactor.spawnProcess(process, xrun, [xrun, '--adapter-id', adapter_id, '--xscope', '--xscope-file', name + '.xmt', bin],
      env=os.environ, path=args.logdir)
Beispiel #3
0
def set_seed(args, test_config):
  """ Set the seed from the config file, unless overridden by the command-line
  """
  seed = 1
  if args.seed is not None:
    seed = args.seed
  elif 'seed' in test_config:
    seed = test_config['seed']

  log_info("Running test with seed {seed}".format(seed=seed))
  random.seed(seed)
Beispiel #4
0
def startXrunWithDelay(rootDir, master, delay, name, adapter_id, args):
  # Need to ensure that the endpoint and process are created and registered before the
  # master task is started
  ep = process.XrunProcess(name, master,
      output_file=os.path.join(args.logdir, name + '_console.log'))
  ep_bin = os.path.join(rootDir, 'sw_avb_dc', 'app_daisy_chain', 'bin', 'app_daisy_chain.xe')

  log_info("Starting %s in %.3f" % (name, delay))
  d = defer.Deferred()
  reactor.callLater(delay, d.callback, (name, ep, adapter_id, ep_bin, args))
  d.addCallback(startXrun)
Beispiel #5
0
def startAnalyzer(combined_args):
  (name, adapter_id, target_bin, analyzer_bin, target_process, analyzer_process, port, args) = combined_args

  # Windows requires the absolute path of xrun
  exe_name = base.exe_name('xrun')
  xrun = base.file_abspath(exe_name)

  log_info("Starting analyzer %s" % name)

  reactor.spawnProcess(target_process, xrun,
      [xrun, '--adapter-id', adapter_id, '--xscope-port', 'localhost:%d' % port, target_bin],
      env=os.environ, path=args.logdir)

  reactor.spawnProcess(analyzer_process, analyzer_bin, [analyzer_bin, '-p', '%d' % port],
      env=os.environ, path=args.logdir)
Beispiel #6
0
def start_generator_with_delay(rootDir, master, delay, name, adapter_id, generator, args):
  # Need to ensure that the endpoint and process are created and registered before the
  # master task is started
  generator_process = process.Process(name, master, output_file=os.path.join(args.logdir, name + '_console.log'))

  target_name = name + '_target'
  target_process = process.XrunProcess(target_name, master,
      output_file=os.path.join(args.logdir, target_name + '_console.log'))

  target_bin = os.path.join(rootDir, 'sw_ethernet_traffic_gen', 'app_traffic_gen', 'bin', 'app_traffic_gen.xe')
  generator_bin = os.path.join(rootDir, 'sw_ethernet_traffic_gen', 'host_traffic_gen', 'traffic_gen_controller')

  log_info("Starting generator %s in %.3f" % (name, delay))
  d = defer.Deferred()
  reactor.callLater(delay, d.callback, (name, adapter_id, target_bin, generator_bin,
       target_process, generator_process, generator['port'], args))
  d.addCallback(start_generator)
Beispiel #7
0
def configure_generators():
  """ Ensure the generators have started properly
  """
  generator_startup = [Expected(a, "connected to .*: %d" % generators.get_port(a), 15, critical=True)
                        for a in generators.get_all()]
  yield master.expect(AllOf(generator_startup))

  for (name,generator) in generators.get_all().iteritems():
    log_info("Configure %s" % name)

    # Configure a random mix of unicast, multicast and broadcast traffic
    master.sendLine(name, "c u 1 64 1500")
    master.sendLine(name, "c m 1 64 1500")
    master.sendLine(name, "c b 1 64 1500")

    # Apply the specified config
    master.sendLine(name, "e")

    # Apply the specified config
    master.sendLine(name, "p")
    yield master.expect(Expected(name, "Current configuration", 5))
Beispiel #8
0
def configure_analyzers():
  """ Ensure the analyzers have started properly and then configure their channel
      frequencies as specified in the test configuration file
  """
  analyzer_startup = [Expected(a, "connected to .*: %d" % analyzers.get_port(a), 15, critical=True)
                        for a in analyzers.get_all()]
  yield master.expect(AllOf(analyzer_startup))

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

    log_info("Configure %s" % name)

    # Disable all channels
    master.sendLine(name, "d a")
    yield master.expect(Expected(name, "Channel 0: disabled", 15))

    # Set the base channel index
    analyzer_base = analyzer['base']
    master.sendLine(name, "b %d" % analyzer_base)

    # Configure all channels
    for (chan_id,freq) in analyzer['frequencies'].iteritems():
      # Need to convert unicode to string before sending as a command
      chan = int(chan_id)
      master.sendLine(name, "c %d %d" % (chan, freq))

      # The channel ID is offset from the base in the generating message
      yield master.expect(
          Expected(name, "Generating sine table for chan %d" % (chan - analyzer_base), 15))

    master.sendLine(name, "e a")
    channel_enables = [Expected(name, "Channel %d: enabled" % (int(c) - analyzer_base), 15)
                        for c in analyzer['frequencies'].keys()]
    yield master.expect(AllOf(channel_enables))
Beispiel #9
0
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))
Beispiel #10
0
def startAnalyzerWithDelay(rootDir, master, delay, name, adapter_id, analyzer, args):
  # Need to ensure that the endpoint and process are created and registered before the
  # master task is started
  analyzer_process = process.Process(name, master,
      output_file=os.path.join(args.logdir, name + '_console.log'))

  target_name = name + '_target'
  target_process = process.XrunProcess(target_name, master,
      output_file=os.path.join(args.logdir, target_name + '_console.log'))

  if analyzer['type'] == 'audio':
    target_bin = os.path.join(rootDir, 'sw_audio_analyzer', 'app_audio_analyzer_avb', 'bin', 'audio_analyzer.xe')
    analyzer_bin = os.path.join(rootDir, 'sw_audio_analyzer', 'host_audio_analyzer', 'audio_analyzer')
  elif analyzer['type'] == 'qav':
    target_bin = os.path.join(rootDir, 'sw_ethernet_tap', 'app_avb_tester', 'bin', 'app_avb_tester.xe')
    analyzer_bin = os.path.join(rootDir, 'sw_ethernet_tap', 'host_avb_tester', 'avb_tester')
  else:
    test_error("%s: unknown type '%s'" % (name, analyzer['type']), critical=True)

  log_info("Starting %s analyzer %s in %.3f" % (analyzer['type'], name, delay))
  d = defer.Deferred()
  reactor.callLater(delay, d.callback, (name, adapter_id, target_bin, analyzer_bin,
       target_process, analyzer_process, analyzer['port'], args))
  d.addCallback(startAnalyzer)
Beispiel #11
0
def print_title(title):
    log_info("\n%s\n%s\n" % (title, '=' * len(title)))
Beispiel #12
0
def print_comment(test_step):
  comment = getattr(test_step, 'comment', None)
  if comment is not None:
    log_info("\n>> %s\n" % comment)