def testSample(self):
     sample = {
         'factory_properties': {
             'gclient_env': {
                 'GYP_DEFINES': 'tiger=1 buffalo=0 giraffe'
             }
         }
     }
     self.assertTrue(slave_utils.GypFlagIsOn(sample, 'tiger'))
     self.assertFalse(slave_utils.GypFlagIsOn(sample, 'buffalo'))
     self.assertTrue(slave_utils.GypFlagIsOn(sample, 'giraffe'))
     self.assertFalse(slave_utils.GypFlagIsOn(sample, 'monkey'))
    def __init__(self, options, build_revision):
        """Sets a number of file and directory paths for convenient use."""

        self.options = options
        self._src_dir = os.path.abspath(options.src_dir)
        self._chrome_dir = os.path.join(self._src_dir, 'chrome')

        build_dir = build_directory.GetBuildOutputDirectory()
        self._build_dir = os.path.join(build_dir, options.target)
        if chromium_utils.IsWindows():
            self._tool_dir = os.path.join(self._chrome_dir, 'tools', 'build',
                                          'win')
        elif chromium_utils.IsLinux():
            # On Linux, we might have built for chromeos.  Archive the same.
            if (options.factory_properties.get('chromeos', None)
                    or slave_utils.GypFlagIsOn(options, 'chromeos')):
                self._tool_dir = os.path.join(self._chrome_dir, 'tools',
                                              'build', 'chromeos')
            # Or, we might have built for Android.
            elif options.factory_properties.get('target_os') == 'android':
                self._tool_dir = os.path.join(self._chrome_dir, 'tools',
                                              'build', 'android')
            else:
                self._tool_dir = os.path.join(self._chrome_dir, 'tools',
                                              'build', 'linux')
        elif chromium_utils.IsMac():
            self._tool_dir = os.path.join(self._chrome_dir, 'tools', 'build',
                                          'mac')
        else:
            raise NotImplementedError(
                'Platform "%s" is not currently supported.' % sys.platform)
        self._staging_dir = (options.staging_dir
                             or slave_utils.GetStagingDir(self._src_dir))
        if not os.path.exists(self._staging_dir):
            os.makedirs(self._staging_dir)

        self._symbol_dir_base = options.dirs['symbol_dir_base']
        self._www_dir_base = options.dirs['www_dir_base']

        if options.build_name:
            self._build_name = options.build_name
        else:
            self._build_name = slave_utils.SlaveBuildName(self._src_dir)

        self._symbol_dir_base = os.path.join(self._symbol_dir_base,
                                             self._build_name)
        self._www_dir_base = os.path.join(self._www_dir_base, self._build_name)

        self._version_file = os.path.join(self._chrome_dir, 'VERSION')

        self._chromium_revision = chromium_utils.GetBuildSortKey(options)[1]

        self._v8_revision = chromium_utils.GetBuildSortKey(options,
                                                           project='v8')[1]
        self._v8_revision_git = chromium_utils.GetGitCommit(options,
                                                            project='v8')

        self.last_change_file = os.path.join(self._staging_dir, 'LAST_CHANGE')
        # The REVISIONS file will record the revisions information of the main
        # components Chromium/WebKit/V8.
        self.revisions_path = os.path.join(self._staging_dir, 'REVISIONS')
        self._build_revision = build_revision
        self._build_path_component = str(self._build_revision)

        # Will be initialized in GetLastBuildRevision.
        self.last_chromium_revision = None
        self.last_v8_revision = None

        self._files_file = os.path.join(self._tool_dir,
                                        archive_utils.FILES_FILENAME)
        self._test_files = self.BuildOldFilesList(TEST_FILE_NAME)

        self._dual_upload = options.factory_properties.get(
            'dual_upload', False)
        self._archive_files = None
Ejemplo n.º 3
0
    def __init__(self, options, build_revision):
        """Sets a number of file and directory paths for convenient use."""

        self.options = options
        self._src_dir = os.path.abspath(options.src_dir)
        self._chrome_dir = os.path.join(self._src_dir, 'chrome')
        # TODO: This scode should not be grabbing so deeply into WebKit.
        #       Worse, this code ends up looking at top-of-tree WebKit
        #       instead of the revision in DEPS.
        self._webkit_dir = os.path.join(self._src_dir, 'third_party', 'WebKit',
                                        'Source')
        self._v8_dir = os.path.join(self._src_dir, 'v8')

        build_dir = build_directory.GetBuildOutputDirectory()
        self._build_dir = os.path.join(build_dir, options.target)
        if chromium_utils.IsWindows():
            self._tool_dir = os.path.join(self._chrome_dir, 'tools', 'build',
                                          'win')
        elif chromium_utils.IsLinux():
            # On Linux, we might have built for chromeos.  Archive the same.
            if (options.factory_properties.get('chromeos', None)
                    or slave_utils.GypFlagIsOn(options, 'chromeos')):
                self._tool_dir = os.path.join(self._chrome_dir, 'tools',
                                              'build', 'chromeos')
            # Or, we might have built for Android.
            elif options.factory_properties.get('target_os') == 'android':
                self._tool_dir = os.path.join(self._chrome_dir, 'tools',
                                              'build', 'android')
            else:
                self._tool_dir = os.path.join(self._chrome_dir, 'tools',
                                              'build', 'linux')
        elif chromium_utils.IsMac():
            self._tool_dir = os.path.join(self._chrome_dir, 'tools', 'build',
                                          'mac')
        else:
            raise NotImplementedError(
                'Platform "%s" is not currently supported.' % sys.platform)
        self._staging_dir = slave_utils.GetStagingDir(self._src_dir)

        self._symbol_dir_base = options.dirs['symbol_dir_base']
        self._www_dir_base = options.dirs['www_dir_base']

        if options.build_name:
            self._build_name = options.build_name
        else:
            self._build_name = slave_utils.SlaveBuildName(self._src_dir)

        self._symbol_dir_base = os.path.join(self._symbol_dir_base,
                                             self._build_name)
        self._www_dir_base = os.path.join(self._www_dir_base, self._build_name)

        self._version_file = os.path.join(self._chrome_dir, 'VERSION')

        if options.default_chromium_revision:
            self._chromium_revision = options.default_chromium_revision
        else:
            self._chromium_revision = slave_utils.GetHashOrRevision(
                os.path.dirname(
                    self._chrome_dir))  # src/ instead of src/chrome
        if options.default_webkit_revision:
            self._webkit_revision = options.default_webkit_revision
        else:
            self._webkit_revision = slave_utils.GetHashOrRevision(
                os.path.dirname(
                    self._webkit_dir))  # WebKit/ instead of WebKit/Source
        if options.default_v8_revision:
            self._v8_revision = options.default_v8_revision
        else:
            self._v8_revision = slave_utils.GetHashOrRevision(self._v8_dir)
        self.last_change_file = os.path.join(self._staging_dir, 'LAST_CHANGE')
        # The REVISIONS file will record the revisions information of the main
        # components Chromium/WebKit/V8.
        self.revisions_path = os.path.join(self._staging_dir, 'REVISIONS')
        self._build_revision = build_revision
        # Will be initialized in GetLastBuildRevision.
        self.last_chromium_revision = None
        self.last_webkit_revision = None
        self.last_v8_revision = None

        self._files_file = os.path.join(self._tool_dir,
                                        archive_utils.FILES_FILENAME)
        self._test_files = self.BuildOldFilesList(TEST_FILE_NAME)

        self._dual_upload = options.factory_properties.get(
            'dual_upload', False)
        self._archive_files = None
Ejemplo n.º 4
0
def main_linux(options, args):
    if len(args) < 1:
        raise chromium_utils.MissingArgument('Usage: %s' % USAGE)

    build_dir = os.path.normpath(os.path.abspath(options.build_dir))
    slave_name = slave_utils.SlaveBuildName(build_dir)
    # If this is a sub-project build (i.e. there's a 'sconsbuild' in build_dir),
    # look for the test binaries there, otherwise look for the top-level build
    # output.
    # This assumes we never pass a build_dir which might contain build output that
    # we're not trying to test. This is currently a safe assumption since we don't
    # have any builders that do both sub-project and top-level builds (only
    # Modules builders do sub-project builds), so they shouldn't ever have both
    # 'build_dir/sconsbuild' and 'build_dir/../sconsbuild'.
    outdir = None
    if os.path.exists(os.path.join(build_dir, 'sconsbuild')):
        outdir = 'sconsbuild'
    elif os.path.exists(os.path.join(build_dir, 'out')):
        outdir = 'out'

    if outdir:
        bin_dir = os.path.join(build_dir, outdir, options.target)
        src_dir = os.path.join(slave_utils.SlaveBaseDir(build_dir), 'build',
                               'src')
        os.environ['CR_SOURCE_ROOT'] = src_dir
    else:
        if os.path.exists(os.path.join(build_dir, '..', 'sconsbuild')):
            bin_dir = os.path.join(build_dir, '..', 'sconsbuild',
                                   options.target)
        else:
            bin_dir = os.path.join(build_dir, '..', 'out', options.target)

    # Figure out what we want for a special frame buffer directory.
    special_xvfb_dir = None
    if options.special_xvfb == 'auto':
        fp_special_xvfb = options.factory_properties.get('special_xvfb', None)
        fp_chromeos = options.factory_properties.get('chromeos', None)
        if fp_special_xvfb or (
                fp_special_xvfb is None and
            (fp_chromeos or slave_utils.GypFlagIsOn(options, 'use_aura')
             or slave_utils.GypFlagIsOn(options, 'chromeos'))):
            special_xvfb_dir = options.special_xvfb_dir
    elif options.special_xvfb:
        special_xvfb_dir = options.special_xvfb_dir

    test_exe = args[0]
    test_exe_path = os.path.join(bin_dir, test_exe)
    if not os.path.exists(test_exe_path):
        if options.factory_properties.get('succeed_on_missing_exe', False):
            print '%s missing but succeed_on_missing_exe used, exiting' % (
                test_exe_path)
            return 0
        msg = 'Unable to find %s' % test_exe_path
        raise chromium_utils.PathNotFound(msg)

    # Decide whether to enable the suid sandbox for Chrome.
    if should_enable_sandbox(CHROME_SANDBOX_PATH):
        print 'Enabling sandbox.  Setting environment variable:'
        print '  CHROME_DEVEL_SANDBOX="%s"' % CHROME_SANDBOX_PATH
        os.environ['CHROME_DEVEL_SANDBOX'] = CHROME_SANDBOX_PATH
    else:
        print 'Disabling sandbox.  Setting environment variable:'
        print '  CHROME_DEVEL_SANDBOX=""'
        os.environ['CHROME_DEVEL_SANDBOX'] = ''

    # Nuke anything that appears to be stale chrome items in the temporary
    # directory from previous test runs (i.e.- from crashes or unittest leaks).
    slave_utils.RemoveChromeTemporaryFiles()

    os.environ['LD_LIBRARY_PATH'] = '%s:%s/lib:%s/lib.target' % (
        bin_dir, bin_dir, bin_dir)
    # Figure out what we want for a special llvmpipe directory.
    if (options.llvmpipe_dir and os.path.exists(options.llvmpipe_dir)):
        os.environ['LD_LIBRARY_PATH'] += ':' + options.llvmpipe_dir

    if options.parallel:
        command = _BuildParallelCommand(build_dir, test_exe_path, options)
    elif options.run_shell_script:
        command = ['bash', test_exe_path]
    elif options.run_python_script:
        command = [sys.executable, test_exe]
    else:
        command = [test_exe_path]
    command.extend(args[1:])

    results_tracker = None
    if options.generate_json_file:
        results_tracker = gtest_slave_utils.GTestUnexpectedDeathTracker()

        if os.path.exists(options.test_output_xml):
            # remove the old XML output file.
            os.remove(options.test_output_xml)

    try:
        http_server = None
        if options.document_root:
            http_server = start_http_server(
                'linux',
                build_dir=build_dir,
                test_exe_path=test_exe_path,
                document_root=options.document_root)
        if options.xvfb:
            xvfb.StartVirtualX(slave_name,
                               bin_dir,
                               with_wm=options.factory_properties.get(
                                   'window_manager', True),
                               server_dir=special_xvfb_dir)
        if options.factory_properties.get('asan', False):
            symbolize = os.path.abspath(
                os.path.join('src', 'tools', 'valgrind', 'asan',
                             'asan_symbolize.py'))
            pipes = [[sys.executable, symbolize], ['c++filt']]
            result = _RunGTestCommand(command, pipes=pipes)
        else:
            result = _RunGTestCommand(command, results_tracker)
    finally:
        if http_server:
            http_server.StopServer()
        if options.xvfb:
            xvfb.StopVirtualX(slave_name)

    if options.generate_json_file:
        _GenerateJSONForTestResults(options, results_tracker)

    return result
Ejemplo n.º 5
0
def _Main(options, args, extra_env):
    """Using the target build configuration, run the executable given in the
  first non-option argument, passing any following arguments to that
  executable.

  Args:
    options: Command-line options for this invocation of runtest.py.
    args: Command and arguments for the test.
    extra_env: A dictionary of extra environment variables to set.

  Returns:
    Exit status code.
  """
    if len(args) < 1:
        raise chromium_utils.MissingArgument('Usage: %s' % USAGE)

    xvfb_path = os.path.join(os.path.dirname(sys.argv[0]), '..', '..',
                             'third_party', 'xvfb',
                             platform.architecture()[0])
    special_xvfb_dir = None
    fp_chromeos = options.factory_properties.get('chromeos', None)
    if (fp_chromeos or slave_utils.GypFlagIsOn(options, 'use_aura')
            or slave_utils.GypFlagIsOn(options, 'chromeos')):
        special_xvfb_dir = xvfb_path

    build_dir = os.path.normpath(os.path.abspath(options.build_dir))
    bin_dir = os.path.join(build_dir, options.target)
    slave_name = options.slave_name or slave_utils.SlaveBuildName(build_dir)

    test_exe = args[0]
    if options.run_python_script:
        test_exe_path = test_exe
    else:
        test_exe_path = os.path.join(bin_dir, test_exe)

    if not os.path.exists(test_exe_path):
        if options.factory_properties.get('succeed_on_missing_exe', False):
            print '%s missing but succeed_on_missing_exe used, exiting' % (
                test_exe_path)
            return 0
        raise chromium_utils.PathNotFound('Unable to find %s' % test_exe_path)

    if sys.platform == 'linux2':
        # Unset http_proxy and HTTPS_PROXY environment variables.  When set, this
        # causes some tests to hang.  See http://crbug.com/139638 for more info.
        if 'http_proxy' in os.environ:
            del os.environ['http_proxy']
            print 'Deleted http_proxy environment variable.'
        if 'HTTPS_PROXY' in os.environ:
            del os.environ['HTTPS_PROXY']
            print 'Deleted HTTPS_PROXY environment variable.'

        # Path to SUID sandbox binary. This must be installed on all bots.
        extra_env['CHROME_DEVEL_SANDBOX'] = CHROME_SANDBOX_PATH

        extra_env['LD_LIBRARY_PATH'] = ''
        if options.enable_lsan:
            # Use the debug version of libstdc++ under LSan. If we don't, there will
            # be a lot of incomplete stack traces in the reports.
            extra_env['LD_LIBRARY_PATH'] += '/usr/lib/x86_64-linux-gnu/debug:'
        extra_env['LD_LIBRARY_PATH'] += '%s:%s/lib:%s/lib.target' % (
            bin_dir, bin_dir, bin_dir)

    if options.run_shell_script:
        command = ['bash', test_exe_path]
    elif options.run_python_script:
        command = [sys.executable, test_exe]
    else:
        command = _BuildTestBinaryCommand(build_dir, test_exe_path, options)
    command.extend(args[1:])

    # Nuke anything that appears to be stale chrome items in the temporary
    # directory from previous test runs (i.e.- from crashes or unittest leaks).
    slave_utils.RemoveChromeTemporaryFiles()

    log_processor = None
    if _UsingGtestJson(options):
        log_processor = gtest_utils.GTestJSONParser(
            options.build_properties.get('mastername'))

    if options.generate_json_file:
        if os.path.exists(options.test_output_xml):
            # remove the old XML output file.
            os.remove(options.test_output_xml)

    try:
        # TODO(dpranke): checking on test_exe is a temporary hack until we
        # can change the buildbot master to pass --xvfb instead of --no-xvfb
        # for these two steps. See
        # https://code.google.com/p/chromium/issues/detail?id=179814
        start_xvfb = (sys.platform == 'linux2'
                      and (options.xvfb or 'layout_test_wrapper' in test_exe
                           or 'devtools_perf_test_wrapper' in test_exe))
        if start_xvfb:
            xvfb.StartVirtualX(slave_name,
                               bin_dir,
                               with_wm=(options.factory_properties.get(
                                   'window_manager', 'True') == 'True'),
                               server_dir=special_xvfb_dir)

        if _UsingGtestJson(options):
            json_file_name = log_processor.PrepareJSONFile(
                options.test_launcher_summary_output)
            command.append('--test-launcher-summary-output=%s' %
                           json_file_name)

        pipes = []
        # See the comment in main() regarding offline symbolization.
        if options.use_symbolization_script:
            symbolize_command = _GetSanitizerSymbolizeCommand(
                strip_path_prefix=options.strip_path_prefix)
            pipes = [symbolize_command]

        command = _GenerateRunIsolatedCommand(build_dir, test_exe_path,
                                              options, command)
        result = _RunGTestCommand(options, command, extra_env, pipes=pipes)
    finally:
        if start_xvfb:
            xvfb.StopVirtualX(slave_name)
        if _UsingGtestJson(options):
            if options.use_symbolization_script:
                _SymbolizeSnippetsInJSON(options, json_file_name)
            log_processor.ProcessJSONFile(options.build_dir)

    if options.generate_json_file:
        if not _GenerateJSONForTestResults(options, log_processor):
            return 1

    if options.annotate:
        annotation_utils.annotate(options.test_type, result, log_processor)

    return result