Exemplo n.º 1
0
def ensureBuild(options):
    if options.existingBuildDir:
        # Pre-downloaded treeherder builds (browser only for now)
        bDir = options.existingBuildDir
        bType = 'local-build'
        bSrc = bDir
        bRev = ''
        manyTimedRunArgs = []
    elif not options.useTreeherderBuilds:
        # Compiled browser
        options.buildOptions = buildBrowser.parseOptions(
            options.buildOptions.split())
        bDir = options.buildOptions.objDir
        bType = platform.system() + "-" + os.path.basename(
            options.buildOptions.mozconfig)
        bSrc = repr(hgCmds.getRepoHashAndId(options.buildOptions.repoDir))
        bRev = ''
        manyTimedRunArgs = []
        success = buildBrowser.tryCompiling(options.buildOptions)
        if not success:
            raise Exception('Building a browser failed.')
    else:
        # Treeherder browser
        # Download from Treeherder and call it 'build'
        # FIXME: Put 'build' somewhere nicer, like ~/fuzzbuilds/. Don't re-download a build that's up to date.
        # FIXME: randomize branch selection, get appropriate builds, use appropriate known dirs
        bDir = 'build'
        bType = downloadBuild.defaultBuildType(options.repoName, None, True)
        bSrc = downloadBuild.downloadLatestBuild(bType,
                                                 './',
                                                 getJsShell=False,
                                                 wantTests=True)
        bRev = ''

        # These two lines are only used for treeherder js shells:
        shell = os.path.join(bDir, "dist", "js.exe" if sps.isWin else "js")
        manyTimedRunArgs = [
            "--random-flags",
            str(JS_SHELL_DEFAULT_TIMEOUT), "mozilla-central", shell
        ]

    return BuildInfo(bDir, bType, bSrc, bRev, manyTimedRunArgs)
Exemplo n.º 2
0
def parseOpts():
    usage = 'Usage: %prog [options]'
    parser = OptionParser(usage)
    # http://docs.python.org/library/optparse.html#optparse.OptionParser.disable_interspersed_args
    parser.disable_interspersed_args()

    parser.set_defaults(
        resetRepoFirst=False,
        startRepo=None,
        endRepo='default',
        testInitialRevs=True,
        output='',
        watchExitCode=None,
        useInterestingnessTests=False,
        parameters=
        '-e 42',  # http://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy
        compilationFailedLabel='skip',
        buildOptions="",
        useTreeherderBinaries=False,
        nameOfTreeherderBranch='mozilla-inbound',
    )

    # Specify how the shell will be built.
    # See buildOptions.py for details.
    parser.add_option(
        '-b',
        '--build',
        dest='buildOptions',
        help=
        'Specify js shell build options, e.g. -b "--enable-debug --32" (python buildOptions.py --help)'
    )
    parser.add_option(
        '-B',
        '--browser',
        dest='browserOptions',
        help='Specify browser build options, e.g. -b "-c mozconfig"')

    parser.add_option(
        '--resetToTipFirst',
        dest='resetRepoFirst',
        action='store_true',
        help='First reset to default tip overwriting all local changes. ' +
        'Equivalent to first executing `hg update -C default`. ' +
        'Defaults to "%default".')

    # Specify the revisions between which to bisect.
    parser.add_option(
        '-s',
        '--startRev',
        dest='startRepo',
        help=
        'Earliest changeset/build numeric ID to consider (usually a "good" cset). '
        + 'Defaults to the earliest revision known to work at all/available.')
    parser.add_option(
        '-e',
        '--endRev',
        dest='endRepo',
        help=
        'Latest changeset/build numeric ID to consider (usually a "bad" cset). '
        +
        'Defaults to the head of the main branch, "default", or latest available build.'
    )
    parser.add_option(
        '-k',
        '--skipInitialRevs',
        dest='testInitialRevs',
        action='store_false',
        help=
        'Skip testing the -s and -e revisions and automatically trust them ' +
        'as -g and -b.')

    # Specify the type of failure to look for.
    # (Optional -- by default, internalTestAndLabel will look for exit codes that indicate a crash or assert.)
    parser.add_option(
        '-o',
        '--output',
        dest='output',
        help='Stdout or stderr output to be observed. Defaults to "%default". '
        + 'For assertions, set to "ssertion fail"')
    parser.add_option(
        '-w',
        '--watchExitCode',
        dest='watchExitCode',
        type='int',
        help='Look out for a specific exit code. Only this exit code will be '
        + 'considered "bad".')
    parser.add_option(
        '-i',
        '--useInterestingnessTests',
        dest='useInterestingnessTests',
        action="store_true",
        help="Interpret the final arguments as an interestingness test.")

    # Specify parameters for the js shell.
    parser.add_option(
        '-p',
        '--parameters',
        dest='parameters',
        help=
        'Specify parameters for the js shell, e.g. -p "-a --ion-eager testcase.js".'
    )

    # Specify how to treat revisions that fail to compile.
    # (You might want to add these to kbew.knownBrokenRanges in knownBrokenEarliestWorking.py.)
    parser.add_option(
        '-l',
        '--compilationFailedLabel',
        dest='compilationFailedLabel',
        help='Specify how to treat revisions that fail to compile. ' +
        '(bad, good, or skip) Defaults to "%default"')

    parser.add_option(
        '-T',
        '--useTreeherderBinaries',
        dest='useTreeherderBinaries',
        action="store_true",
        help='Use treeherder binaries for quick bisection, assuming a fast ' +
        'internet connection. Defaults to "%default"')
    parser.add_option(
        '-N',
        '--nameOfTreeherderBranch',
        dest='nameOfTreeherderBranch',
        help='Name of the branch to download. Defaults to "%default"')

    (options, args) = parser.parse_args()
    if options.browserOptions:
        assert not options.buildOptions
        options.browserOptions = buildBrowser.parseOptions(
            options.browserOptions.split())
        options.skipRevs = ' + '.join(
            kbew.knownBrokenRangesBrowser(options.browserOptions))
    else:
        options.buildOptions = buildOptions.parseShellOptions(
            options.buildOptions)
        options.skipRevs = ' + '.join(
            kbew.knownBrokenRanges(options.buildOptions))

    options.paramList = [
        sps.normExpUserPath(x) for x in options.parameters.split(' ') if x
    ]
    # First check that the testcase is present.
    if '-e 42' not in options.parameters and not os.path.isfile(
            options.paramList[-1]):
        print '\nList of parameters to be passed to the shell is: ' + ' '.join(
            options.paramList)
        print
        raise Exception('Testcase at ' + options.paramList[-1] +
                        ' is not present.')

    assert options.compilationFailedLabel in ('bad', 'good', 'skip')

    extraFlags = []

    if options.useInterestingnessTests:
        if len(args) < 1:
            print 'args are: ' + args
            parser.error('Not enough arguments.')
        if not options.browserOptions:
            for a in args:
                if a.startswith("--flags="):
                    extraFlags = a[8:].split(' ')
        options.testAndLabel = externalTestAndLabel(options, args)
    else:
        assert not options.browserOptions  # autoBisect doesn't have a built-in way to run the browser
        if len(args) >= 1:
            parser.error('Too many arguments.')
        options.testAndLabel = internalTestAndLabel(options)

    if options.browserOptions:
        earliestKnownQuery = kbew.earliestKnownWorkingRevForBrowser(
            options.browserOptions)
    else:
        earliestKnownQuery = kbew.earliestKnownWorkingRev(
            options.buildOptions, options.paramList + extraFlags,
            options.skipRevs)

    earliestKnown = ''

    if not options.useTreeherderBinaries:
        earliestKnown = hgCmds.getRepoHashAndId(options.buildOptions.repoDir,
                                                repoRev=earliestKnownQuery)[0]

    if options.startRepo is None:
        if options.useTreeherderBinaries:
            options.startRepo = 'default'
        else:
            options.startRepo = earliestKnown
    # elif not (options.useTreeherderBinaries or hgCmds.isAncestor(options.buildOptions.repoDir, earliestKnown, options.startRepo)):
    #     raise Exception('startRepo is not a descendant of kbew.earliestKnownWorkingRev for this configuration')
    #
    # if not options.useTreeherderBinaries and not hgCmds.isAncestor(options.buildOptions.repoDir, earliestKnown, options.endRepo):
    #     raise Exception('endRepo is not a descendant of kbew.earliestKnownWorkingRev for this configuration')

    if options.parameters == '-e 42':
        print "Note: since no parameters were specified, we're just ensuring the shell does not crash on startup/shutdown."

    if options.nameOfTreeherderBranch != 'mozilla-inbound' and not options.useTreeherderBinaries:
        raise Exception(
            'Setting the name of branches only works for treeherder shell bisection.'
        )

    return options
Exemplo n.º 3
0
def ensureBuild(options):
    if options.existingBuildDir:
        # Pre-downloaded treeherder builds (browser only for now)
        bDir = options.existingBuildDir
        bType = 'local-build'
        bSrc = bDir
        bRev = ''
        manyTimedRunArgs = []
    elif not options.useTreeherderBuilds:
        if options.testType == "js":
            # Compiled js shells
            options.buildOptions = buildOptions.parseShellOptions(
                options.buildOptions)
            options.timeout = options.timeout or machineTimeoutDefaults(
                options)

            with LockDir(
                    compileShell.getLockDirPath(options.buildOptions.repoDir)):
                bRev = hgCmds.getRepoHashAndId(options.buildOptions.repoDir)[0]
                cshell = compileShell.CompiledShell(options.buildOptions, bRev)
                compileShell.obtainShell(cshell, updateLatestTxt=True)

                bDir = cshell.getShellCacheDir()
                # Strip out first 3 chars or else the dir name in fuzzing jobs becomes:
                #   js-js-dbg-opt-64-dm-linux
                # This is because options.testType gets prepended along with a dash later.
                bType = buildOptions.computeShellType(options.buildOptions)[3:]
                bSrc = (
                    'Create another shell in shell-cache like this one:\n' +
                    'python -u %s -b "%s -R %s" -r %s\n\n' %
                    (os.path.join(path3, 'compileShell.py'),
                     options.buildOptions.buildOptionsStr,
                     options.buildOptions.repoDir, bRev) +
                    '==============================================\n' +
                    '|  Fuzzing %s js shell builds\n' % cshell.getRepoName() +
                    '|  DATE: %s\n' % sps.dateStr() +
                    '==============================================\n\n')

                manyTimedRunArgs = mtrArgsCreation(options, cshell)
                print 'buildDir is: ' + bDir
                print 'buildSrc is: ' + bSrc
        else:
            # Compiled browser
            options.buildOptions = buildBrowser.parseOptions(
                options.buildOptions.split())
            bDir = options.buildOptions.objDir
            bType = platform.system() + "-" + os.path.basename(
                options.buildOptions.mozconfig)
            bSrc = repr(hgCmds.getRepoHashAndId(options.buildOptions.repoDir))
            bRev = ''
            manyTimedRunArgs = []
            success = buildBrowser.tryCompiling(options.buildOptions)
            if not success:
                raise Exception('Building a browser failed.')
    else:
        # Treeherder js shells and browser
        # Download from Treeherder and call it 'build'
        # FIXME: Put 'build' somewhere nicer, like ~/fuzzbuilds/. Don't re-download a build that's up to date.
        # FIXME: randomize branch selection, get appropriate builds, use appropriate known dirs
        bDir = 'build'
        bType = downloadBuild.defaultBuildType(options.repoName, None, True)
        bSrc = downloadBuild.downloadLatestBuild(
            bType, './', getJsShell=(options.testType == 'js'))
        bRev = ''

        # These two lines are only used for treeherder js shells:
        shell = os.path.join(bDir, "dist", "js.exe" if sps.isWin else "js")
        manyTimedRunArgs = [
            "--random-flags",
            str(JS_SHELL_DEFAULT_TIMEOUT), "mozilla-central", shell
        ]

    return BuildInfo(bDir, bType, bSrc, bRev, manyTimedRunArgs)
Exemplo n.º 4
0
def ensureBuild(options):
    if options.existingBuildDir:
        # Pre-downloaded treeherder builds (browser only for now)
        bDir = options.existingBuildDir
        bType = 'local-build'
        bSrc = bDir
        bRev = ''
        manyTimedRunArgs = []
    elif not options.useTreeherderBuilds:
        if options.testType == "js":
            # Compiled js shells
            options.buildOptions = buildOptions.parseShellOptions(options.buildOptions)
            options.timeout = options.timeout or machineTimeoutDefaults(options)

            with LockDir(compileShell.getLockDirPath(options.buildOptions.repoDir)):
                bRev = hgCmds.getRepoHashAndId(options.buildOptions.repoDir)[0]
                cshell = compileShell.CompiledShell(options.buildOptions, bRev)
                compileShell.obtainShell(cshell, updateLatestTxt=True)

                bDir = cshell.getShellCacheDir()
                # Strip out first 3 chars or else the dir name in fuzzing jobs becomes:
                #   js-js-dbg-opt-64-dm-linux
                # This is because options.testType gets prepended along with a dash later.
                bType = buildOptions.computeShellType(options.buildOptions)[3:]
                bSrc = (
                    'Create another shell in shell-cache like this one:\n' +
                    'python -u %s -b "%s -R %s" -r %s\n\n' % (
                        os.path.join(path3, 'compileShell.py'), options.buildOptions.buildOptionsStr,
                        options.buildOptions.repoDir, bRev
                    ) +
                    '==============================================\n' +
                    '|  Fuzzing %s js shell builds\n'  % cshell.getRepoName() +
                    '|  DATE: %s\n'                    % sps.dateStr() +
                    '==============================================\n\n')

                manyTimedRunArgs = mtrArgsCreation(options, cshell)
                print 'buildDir is: ' + bDir
                print 'buildSrc is: ' + bSrc
        else:
            # Compiled browser
            options.buildOptions = buildBrowser.parseOptions(options.buildOptions.split())
            bDir = options.buildOptions.objDir
            bType = platform.system() + "-" + os.path.basename(options.buildOptions.mozconfig)
            bSrc = repr(hgCmds.getRepoHashAndId(options.buildOptions.repoDir))
            bRev = ''
            manyTimedRunArgs = []
            success = buildBrowser.tryCompiling(options.buildOptions)
            if not success:
                raise Exception('Building a browser failed.')
    else:
        # Treeherder js shells and browser
        # Download from Treeherder and call it 'build'
        # FIXME: Put 'build' somewhere nicer, like ~/fuzzbuilds/. Don't re-download a build that's up to date.
        # FIXME: randomize branch selection, get appropriate builds, use appropriate known dirs
        bDir = 'build'
        bType = downloadBuild.defaultBuildType(options.repoName, None, True)
        bSrc = downloadBuild.downloadLatestBuild(bType, './', getJsShell=(options.testType == 'js'))
        bRev = ''

        # These two lines are only used for treeherder js shells:
        shell = os.path.join(bDir, "dist", "js.exe" if sps.isWin else "js")
        manyTimedRunArgs = ["--random-flags", str(JS_SHELL_DEFAULT_TIMEOUT), "mozilla-central", shell]

    return BuildInfo(bDir, bType, bSrc, bRev, manyTimedRunArgs)
Exemplo n.º 5
0
def parseOpts():
    usage = 'Usage: %prog [options]'
    parser = OptionParser(usage)
    # http://docs.python.org/library/optparse.html#optparse.OptionParser.disable_interspersed_args
    parser.disable_interspersed_args()

    parser.set_defaults(
        resetRepoFirst=False,
        startRepo=None,
        endRepo='default',
        testInitialRevs=True,
        output='',
        watchExitCode=None,
        useInterestingnessTests=False,
        parameters='-e 42',  # http://en.wikipedia.org/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy
        compilationFailedLabel='skip',
        buildOptions="",
        useTreeherderBinaries=False,
        nameOfTreeherderBranch='mozilla-inbound',
    )

    # Specify how the shell will be built.
    # See buildOptions.py for details.
    parser.add_option('-b', '--build',
                      dest='buildOptions',
                      help='Specify js shell build options, e.g. -b "--enable-debug --32" (python buildOptions.py --help)')
    parser.add_option('-B', '--browser',
                      dest='browserOptions',
                      help='Specify browser build options, e.g. -b "-c mozconfig"')

    parser.add_option('--resetToTipFirst', dest='resetRepoFirst',
                      action='store_true',
                      help='First reset to default tip overwriting all local changes. ' +
                      'Equivalent to first executing `hg update -C default`. ' +
                      'Defaults to "%default".')

    # Specify the revisions between which to bisect.
    parser.add_option('-s', '--startRev', dest='startRepo',
                      help='Earliest changeset/build numeric ID to consider (usually a "good" cset). ' +
                      'Defaults to the earliest revision known to work at all/available.')
    parser.add_option('-e', '--endRev', dest='endRepo',
                      help='Latest changeset/build numeric ID to consider (usually a "bad" cset). ' +
                      'Defaults to the head of the main branch, "default", or latest available build.')
    parser.add_option('-k', '--skipInitialRevs', dest='testInitialRevs',
                      action='store_false',
                      help='Skip testing the -s and -e revisions and automatically trust them ' +
                      'as -g and -b.')

    # Specify the type of failure to look for.
    # (Optional -- by default, internalTestAndLabel will look for exit codes that indicate a crash or assert.)
    parser.add_option('-o', '--output', dest='output',
                      help='Stdout or stderr output to be observed. Defaults to "%default". ' +
                      'For assertions, set to "ssertion fail"')
    parser.add_option('-w', '--watchExitCode', dest='watchExitCode',
                      type='int',
                      help='Look out for a specific exit code. Only this exit code will be ' +
                      'considered "bad".')
    parser.add_option('-i', '--useInterestingnessTests',
                      dest='useInterestingnessTests',
                      action="store_true",
                      help="Interpret the final arguments as an interestingness test.")

    # Specify parameters for the js shell.
    parser.add_option('-p', '--parameters', dest='parameters',
                      help='Specify parameters for the js shell, e.g. -p "-a --ion-eager testcase.js".')

    # Specify how to treat revisions that fail to compile.
    # (You might want to add these to kbew.knownBrokenRanges in knownBrokenEarliestWorking.py.)
    parser.add_option('-l', '--compilationFailedLabel', dest='compilationFailedLabel',
                      help='Specify how to treat revisions that fail to compile. ' +
                      '(bad, good, or skip) Defaults to "%default"')

    parser.add_option('-T', '--useTreeherderBinaries',
                      dest='useTreeherderBinaries',
                      action="store_true",
                      help='Use treeherder binaries for quick bisection, assuming a fast ' +
                      'internet connection. Defaults to "%default"')
    parser.add_option('-N', '--nameOfTreeherderBranch',
                      dest='nameOfTreeherderBranch',
                      help='Name of the branch to download. Defaults to "%default"')

    (options, args) = parser.parse_args()
    if options.browserOptions:
        assert not options.buildOptions
        options.browserOptions = buildBrowser.parseOptions(options.browserOptions.split())
        options.skipRevs = ' + '.join(kbew.knownBrokenRangesBrowser(options.browserOptions))
    else:
        options.buildOptions = buildOptions.parseShellOptions(options.buildOptions)
        options.skipRevs = ' + '.join(kbew.knownBrokenRanges(options.buildOptions))

    options.paramList = [sps.normExpUserPath(x) for x in options.parameters.split(' ') if x]
    # First check that the testcase is present.
    if '-e 42' not in options.parameters and not os.path.isfile(options.paramList[-1]):
        print '\nList of parameters to be passed to the shell is: ' + ' '.join(options.paramList)
        print
        raise Exception('Testcase at ' + options.paramList[-1] + ' is not present.')

    assert options.compilationFailedLabel in ('bad', 'good', 'skip')

    extraFlags = []

    if options.useInterestingnessTests:
        if len(args) < 1:
            print 'args are: ' + args
            parser.error('Not enough arguments.')
        if not options.browserOptions:
            for a in args:
                if a.startswith("--flags="):
                    extraFlags = a[8:].split(' ')
        options.testAndLabel = externalTestAndLabel(options, args)
    else:
        assert not options.browserOptions  # autoBisect doesn't have a built-in way to run the browser
        if len(args) >= 1:
            parser.error('Too many arguments.')
        options.testAndLabel = internalTestAndLabel(options)

    if options.browserOptions:
        earliestKnownQuery = kbew.earliestKnownWorkingRevForBrowser(options.browserOptions)
    else:
        earliestKnownQuery = kbew.earliestKnownWorkingRev(options.buildOptions, options.paramList + extraFlags, options.skipRevs)

    earliestKnown = ''

    if not options.useTreeherderBinaries:
        earliestKnown = hgCmds.getRepoHashAndId(options.buildOptions.repoDir, repoRev=earliestKnownQuery)[0]

    if options.startRepo is None:
        if options.useTreeherderBinaries:
            options.startRepo = 'default'
        else:
            options.startRepo = earliestKnown
    # elif not (options.useTreeherderBinaries or hgCmds.isAncestor(options.buildOptions.repoDir, earliestKnown, options.startRepo)):
    #     raise Exception('startRepo is not a descendant of kbew.earliestKnownWorkingRev for this configuration')
    #
    # if not options.useTreeherderBinaries and not hgCmds.isAncestor(options.buildOptions.repoDir, earliestKnown, options.endRepo):
    #     raise Exception('endRepo is not a descendant of kbew.earliestKnownWorkingRev for this configuration')

    if options.parameters == '-e 42':
        print "Note: since no parameters were specified, we're just ensuring the shell does not crash on startup/shutdown."

    if options.nameOfTreeherderBranch != 'mozilla-inbound' and not options.useTreeherderBinaries:
        raise Exception('Setting the name of branches only works for treeherder shell bisection.')

    return options