Exemplo n.º 1
0
    def _initConfig(self,
                    bot_id,
                    extra_argv=None,
                    override_hw_test_config=None):
        """Return normal options/build_config for |bot_id|"""
        site_config = chromeos_config.GetConfig()
        build_config = copy.deepcopy(site_config[bot_id])
        build_config['master'] = False
        build_config['important'] = False

        # Use the cbuildbot parser to create properties and populate default values.
        parser = cbuildbot._CreateParser()
        argv = (
            ['-r', self.buildroot, '--buildbot', '--debug', '--nochromesdk'] +
            (extra_argv if extra_argv else []) + [bot_id])
        options, _ = cbuildbot._ParseCommandLine(parser, argv)

        # Yikes.
        options.managed_chrome = build_config['sync_chrome']

        # Iterate through override and update HWTestConfig attributes.
        if override_hw_test_config:
            for key, val in override_hw_test_config.iteritems():
                for hw_test in build_config.hw_tests:
                    setattr(hw_test, key, val)

        return cbuildbot_run.BuilderRun(options, site_config, build_config,
                                        self._manager)
Exemplo n.º 2
0
  def RunAllConfigs(self, task, skip_missing=False, site_config=None):
    """Run |task| against all major configurations"""
    if site_config is None:
      site_config = chromeos_config.GetConfig()

    with parallel.BackgroundTaskRunner(task) as queue:
      # Loop through all major configuration types and pick one from each.
      for bot_type in config_lib.CONFIG_TYPE_DUMP_ORDER:
        for bot_id in site_config:
          if bot_id.endswith(bot_type):
            # Skip any config without a board, since those configs do not
            # build packages.
            cfg = site_config[bot_id]
            if cfg.boards:
              # Skip boards w/out a local overlay.  Like when running a
              # public manifest and testing private-only boards.
              if skip_missing:
                try:
                  for b in cfg.boards:
                    portage_util.FindPrimaryOverlay(constants.BOTH_OVERLAYS, b)
                except portage_util.MissingOverlayException:
                  continue

              queue.put([bot_id])
              break
    def testChromeOsLoad(self):
        """This test compares chromeos_config to config_dump.json."""
        # If there is a test failure, the diff will be big.
        self.maxDiff = None

        src = chromeos_config.GetConfig()
        new = config_lib.LoadConfigFromFile()

        self.assertDictEqual(src.GetDefault(), new.GetDefault())

        #
        # BUG ALERT ON TEST FAILURE
        #
        # assertDictEqual can correctly compare these structs for equivalence, but
        # has a bug when displaying differences on failure. The embedded
        # HWTestConfig values are correctly compared, but ALWAYS display as
        # different, if something else triggers a failure.
        #

        # This for loop is to make differences easier to find/read.
        for name in src.iterkeys():
            self.assertDictEqual(new[name], src[name])

        # This confirms they are exactly the same.
        self.assertDictEqual(new, src)
Exemplo n.º 4
0
def main(argv):
    parser = GetParser()
    options = parser.parse_args(argv)

    site_config = chromeos_config.GetConfig()

    with (open(constants.CHROMEOS_CONFIG_FILE, 'w')
          if options.update_config else sys.stdout) as filehandle:
        if options.full:
            filehandle.write(site_config.DumpExpandedConfigToString())
        else:
            filehandle.write(site_config.SaveConfigToString())
Exemplo n.º 5
0
    def RunAllConfigs(self, task, skip_missing=False, site_config=None):
        """Run |task| against all major configurations"""
        if site_config is None:
            site_config = chromeos_config.GetConfig()

        boards = ('samus', 'arm-generic')

        with parallel.BackgroundTaskRunner(task) as queue:
            # Test every build config on an waterfall, that builds something.
            for bot_id, cfg in site_config.iteritems():
                if not cfg.boards or cfg.boards[0] not in boards:
                    continue

                if skip_missing:
                    try:
                        for b in cfg.boards:
                            portage_util.FindPrimaryOverlay(
                                constants.BOTH_OVERLAYS, b)
                    except portage_util.MissingOverlayException:
                        continue

                queue.put([bot_id])
Exemplo n.º 6
0
 def setUp(self):
     self.real_config = chromeos_config.GetConfig()['test-ap-group']
     self.PatchObject(cbuildbot_run._BuilderRunBase,
                      'GetVersion',
                      return_value=DEFAULT_VERSION)
Exemplo n.º 7
0
 def setUp(self):
     self.all_configs = chromeos_config.GetConfig()
Exemplo n.º 8
0
  def _Prepare(self, bot_id=None, extra_config=None, cmd_args=None,
               extra_cmd_args=None, build_id=DEFAULT_BUILD_ID,
               waterfall=constants.WATERFALL_INTERNAL,
               waterfall_url=constants.BUILD_INT_DASHBOARD,
               master_build_id=None,
               site_config=None):
    """Prepare a BuilderRun at self._run for this test.

    This method must allow being called more than once.  Subclasses can
    override this method, but those subclass methods should also call this one.

    The idea is that all test preparation that falls out from the choice of
    build config and cbuildbot options should go in _Prepare.

    This will populate the following attributes on self:
      run: A BuilderRun object.
      bot_id: The bot id (name) that was used from the site_config.
      self._boards: Same as self._run.config.boards.  TODO(mtennant): remove.
      self._current_board: First board in list, if there is one.

    Args:
      bot_id: Name of build config to use, defaults to self.BOT_ID.
      extra_config: Dict used to add to the build config for the given
        bot_id.  Example: {'push_image': True}.
      cmd_args: List to override the default cbuildbot command args.
      extra_cmd_args: List to add to default cbuildbot command args.  This
        is a good way to adjust an options value for your test.
        Example: ['branch-name', 'some-branch-name'] will effectively cause
        self._run.options.branch_name to be set to 'some-branch-name'.
      build_id: mock build id
      waterfall: Name of the current waterfall.
                 Possibly from constants.CIDB_KNOWN_WATERFALLS.
      waterfall_url: Url for the current waterfall.
      master_build_id: mock build id of master build.
      site_config: SiteConfig to use (or MockSiteConfig)
    """
    # Use cbuildbot parser to create options object and populate default values.
    parser = cbuildbot._CreateParser()
    if not cmd_args:
      # Fill in default command args.
      cmd_args = [
          '-r', self.build_root, '--buildbot', '--noprebuilts',
          '--buildnumber', str(DEFAULT_BUILD_NUMBER),
          '--branch', self.TARGET_MANIFEST_BRANCH,
      ]
    if extra_cmd_args:
      cmd_args += extra_cmd_args
    (options, args) = parser.parse_args(cmd_args)

    # The bot_id can either be specified as arg to _Prepare method or in the
    # cmd_args (as cbuildbot normally accepts it from command line).
    if args:
      self._bot_id = args[0]
      if bot_id:
        # This means bot_id was specified as _Prepare arg and in cmd_args.
        # Make sure they are the same.
        self.assertEquals(self._bot_id, bot_id)
    else:
      self._bot_id = bot_id or self.BOT_ID
      args = [self._bot_id]
    cbuildbot._FinishParsing(options, args)

    if site_config is None:
      site_config = chromeos_config.GetConfig()

    # Populate build_config corresponding to self._bot_id.
    build_config = copy.deepcopy(site_config[self._bot_id])
    build_config['manifest_repo_url'] = 'fake_url'
    if extra_config:
      build_config.update(extra_config)
    if options.remote_trybot:
      build_config = config_lib.OverrideConfigForTrybot(
          build_config, options)
    options.managed_chrome = build_config['sync_chrome']

    self._boards = build_config['boards']
    self._current_board = self._boards[0] if self._boards else None

    # Some preliminary sanity checks.
    self.assertEquals(options.buildroot, self.build_root)

    # Construct a real BuilderRun using options and build_config.
    self._run = cbuildbot_run.BuilderRun(
        options, site_config, build_config, self._manager)

    if build_id is not None:
      self._run.attrs.metadata.UpdateWithDict({'build_id': build_id})

    if master_build_id is not None:
      self._run.options.master_build_id = master_build_id

    self._run.attrs.metadata.UpdateWithDict({'buildbot-master-name': waterfall})
    self._run.attrs.metadata.UpdateWithDict({'buildbot-url': waterfall_url})

    if self.RELEASE_TAG is not None:
      self._run.attrs.release_tag = self.RELEASE_TAG

    portage_util._OVERLAY_LIST_CMD = '/bin/true'
Exemplo n.º 9
0
 def setUp(self):
     self.config = chromeos_config.GetConfig()