Exemple #1
0
 def test_GenArgsOneConfig(self):
   with tempfile.NamedTemporaryFile('w', delete=False) as base_file:
     config = '''{
       "BrowserBlackList": [
         { "group_name": "Enabled" }
       ],
       "c": [
         {
           "group_name": "d.",
           "params": {"url": "http://www.google.com"}
         }
       ],
       "SimpleParams": [
         {
           "group_name": "Default",
           "params": {"id": "abc"}
         }
       ]
     }'''
     try:
       base_file.write(config)
       base_file.close()
       result = fieldtrial_util.GenerateArgs(base_file.name)
       self.assertEqual(['--force-fieldtrials='
           'BrowserBlackList/Enabled/c/d./SimpleParams/Default',
           '--force-fieldtrial-params='
           'c.d%2E:url/http%3A%2F%2Fwww%2Egoogle%2Ecom,'
           'SimpleParams.Default:id/abc'], result)
     finally:
       os.unlink(base_file.name)
Exemple #2
0
def _IsFieldTrialSizeBelowLimitOnWindows(input_api, file_path):
    """Checks whether the fieldtrial parameters exceeded the Windows cmd limit.

  When launching chrome, the fieldtrial related parameters take more than
  30,000 characters. Windows has a limit of 32767 characters on command
  line and thus it raises parameter error when the parameters are too long.
  Before we have a valid fix, we need to limit the number of fieldtrias in
  fieldtrial_testing_config.json to 31,500, from the fact that the
  non-fieldtrial parameters take roughly 1450 characters.
  See crbug.com/1045530 for more details.

  Args:
    input_api: An instance passed to presubmit scripts telling info about the
      changes.
    file_path: the absolute path to the json file with the fieldtrial configs.
  """
    sys.path.append(
        input_api.os_path.join(input_api.PresubmitLocalPath(), '..', '..',
                               'tools', 'variations'))
    import fieldtrial_util

    args = fieldtrial_util.GenerateArgs(file_path, 'windows')
    total_length = 0
    for arg in args:
        total_length += len(arg)
    return total_length < 31500
Exemple #3
0
 def test_GenArgsOverrideConfig(self):
     with tempfile.NamedTemporaryFile('w') as base_file:
         config = '''{
     "a": [
       { "group_name": "b" }
     ],
     "c": [
       { "group_name": "d" }
     ]
   }'''
         base_file.write(config)
         base_file.flush()
         with tempfile.NamedTemporaryFile('w') as platform_file:
             config = '''{
       "a": [
         { "group_name": "1" }
       ],
       "b": [
         { "group_name": "bgroup" }
       ]
     }'''
             platform_file.write(config)
             platform_file.flush()
             result = fieldtrial_util.GenerateArgs(base_file.name,
                                                   platform_file.name)
             self.assertEqual(['--force-fieldtrials='
                               'a/1/c/d/b/bgroup'], result)
Exemple #4
0
 def _GetVariationsBrowserArgs(self, finder_options):
     variations_dir = os.path.join(os.path.dirname(__file__), os.pardir,
                                   os.pardir, os.pardir, 'testing',
                                   'variations')
     target_os = browser_finder.FindBrowser(finder_options).target_os
     return fieldtrial_util.GenerateArgs(
         os.path.join(
             variations_dir, 'fieldtrial_testing_config_%s.json' %
             self._FixupTargetOS(target_os)))
Exemple #5
0
    def _GetVariationsBrowserArgs(self, finder_options):
        variations_dir = os.path.join(os.path.dirname(__file__), '..', '..',
                                      '..', 'testing', 'variations')
        possible_browser = browser_finder.FindBrowser(finder_options)
        if not possible_browser:
            return []

        return fieldtrial_util.GenerateArgs(
            os.path.join(variations_dir, 'fieldtrial_testing_config.json'),
            self._FixupTargetOS(possible_browser.target_os))
 def runGenerateArgs(self, config):
   result = None
   with tempfile.NamedTemporaryFile('w', delete=False) as base_file:
     try:
       base_file.write(config)
       base_file.close()
       result = fieldtrial_util.GenerateArgs(base_file.name)
     finally:
       os.unlink(base_file.name)
   return result
Exemple #7
0
    def _GetVariationsBrowserArgs(self, finder_options, current_args):
        chrome_root = finder_options.chrome_root
        if chrome_root is None:
            chrome_root = path_module.GetChromiumSrcDir()

        variations_dir = os.path.join(chrome_root, 'testing', 'variations')
        possible_browser = browser_finder.FindBrowser(finder_options)
        if not possible_browser:
            return []

        return fieldtrial_util.GenerateArgs(
            os.path.join(variations_dir, 'fieldtrial_testing_config.json'),
            self.FixupTargetOS(possible_browser.target_os), current_args)
def GetExperimentArgs():
  """Returns a list of arguments with all tested field trials.

  This function is a simple wrapper around the variation team's fieldtrail_util
  script that generates command line arguments to test Chromium field trials.

  Returns:
    an array of command line arguments to pass to chrome
  """
  config_path = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
    os.pardir, 'testing', 'variations', 'fieldtrial_testing_config.json')
  my_platform = ''
  if common.ParseFlags().android:
    my_platform = 'android'
  elif platform.system().lower() == 'linux':
    my_platform = 'linux'
  elif platform.system().lower() == 'windows':
    my_platform = 'windows'
  elif platform.system().lower() == 'darwin':
    my_platform = 'mac'
  else:
    raise Exception('unknown platform!')
  return fieldtrial_util.GenerateArgs(config_path, [my_platform])
 def test_GenArgsEmptyPaths(self):
     args = fieldtrial_util.GenerateArgs('', ['linux'])
     self.assertEqual([], args)