Пример #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:
        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)
Пример #2
0
def bisectUsingTboxBins(options):
    """Download treeherder binaries and bisect them."""
    testedIDs = {}
    desiredArch = '32' if options.buildOptions.enable32 else '64'
    buildType = downloadBuild.defaultBuildType(options.nameOfTreeherderBranch,
                                               desiredArch,
                                               options.buildOptions.enableDbg)

    # Get list of treeherder IDs
    urlsTbox = downloadBuild.getBuildList(buildType,
                                          earliestBuild=options.startRepo,
                                          latestBuild=options.endRepo)

    # Download and test starting point.
    print()
    print("Examining starting point...")
    sID, startResult, _sReason, _sPosition, urlsTbox, testedIDs, _startSkippedNum = testBuildOrNeighbour(
        options, 0, urlsTbox, buildType, testedIDs)
    if sID is None:
        raise Exception('No complete builds were found.')
    print("Numeric ID %s was tested." % sID)

    # Download and test ending point.
    print()
    print("Examining ending point...")
    eID, endResult, _eReason, _ePosition, urlsTbox, testedIDs, _endSkippedNum = testBuildOrNeighbour(
        options,
        len(urlsTbox) - 1, urlsTbox, buildType, testedIDs)
    if eID is None:
        raise Exception('No complete builds were found.')
    print("Numeric ID %s was tested." % eID)

    if startResult == endResult:
        raise Exception(
            'Starting and ending points should have opposite results')

    count = 0
    print()
    print("Starting bisection...")
    print()
    while count < MAX_ITERATIONS:
        sps.vdump('Unsorted dictionary of tested IDs is: ' + str(testedIDs))
        count += 1
        print("Test number %d:" % count)

        sortedUrlsTbox = sorted(urlsTbox)
        if len(sortedUrlsTbox) >= 3:
            mPosition = len(sortedUrlsTbox) // 2
        else:
            print()
            print(
                'WARNING: %s has size smaller than 3. Impossible to return "middle" element.'
                % (sortedUrlsTbox, ))
            print()
            mPosition = len(sortedUrlsTbox)

        # Test the middle revision. If it is not a complete build, test ones around it.
        mID, mResult, _mReason, mPosition, urlsTbox, testedIDs, middleRevSkippedNum = testBuildOrNeighbour(
            options, mPosition, urlsTbox, buildType, testedIDs)
        if mID is None:
            print("Middle ID is None.")
            break

        # Refresh the range of treeherder IDs depending on mResult.
        if mResult == endResult:
            urlsTbox = urlsTbox[0:(mPosition + 1)]
        else:
            urlsTbox = urlsTbox[(mPosition):len(urlsTbox)]

        print("Numeric ID %s was tested." % mID, end=" ")

        #  Exit infinite loop once we have tested the starting point, ending point and any points
        #  in the middle with results returning "incomplete".
        if (len(urlsTbox) - middleRevSkippedNum) <= 2 and mID in testedIDs:
            break
        elif len(urlsTbox) < 2:
            print("urlsTbox is: %s" % (urlsTbox, ))
            raise Exception('Length of urlsTbox should not be smaller than 2.')
        elif (len(testedIDs) - 2) > 30:
            raise Exception('Number of testedIDs has exceeded 30.')

        print(showRemainingNumOfTests(urlsTbox))

    print()
    sps.vdump('Build URLs are: ' + str(urlsTbox))
    assert getIdFromTboxUrl(
        urlsTbox[0]) in testedIDs, 'Starting ID should have been tested.'
    assert getIdFromTboxUrl(
        urlsTbox[-1]) in testedIDs, 'Ending ID should have been tested.'
    outputTboxBisectionResults(options, urlsTbox, testedIDs)
Пример #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)
                updateLatestTxt = (options.buildOptions.repoDir == 'mozilla-central')
                compileShell.obtainShell(cshell, updateLatestTxt=updateLatestTxt)

                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)
        isJS = options.testType == 'js'
        bSrc = downloadBuild.downloadLatestBuild(bType, './', getJsShell=isJS, wantTests=not isJS)
        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)
Пример #4
0
def bisectUsingTboxBins(options):
    '''
    Downloads treeherder binaries and bisects them.
    '''
    testedIDs = {}
    desiredArch = '32' if options.buildOptions.enable32 else '64'
    buildType = downloadBuild.defaultBuildType(options.nameOfTreeherderBranch, desiredArch, options.buildOptions.enableDbg)

    # Get list of treeherder IDs
    urlsTbox = downloadBuild.getBuildList(buildType, earliestBuild=options.startRepo, latestBuild=options.endRepo)

    # Download and test starting point.
    print '\nExamining starting point...'
    sID, startResult, sReason, sPosition, urlsTbox, testedIDs, startSkippedNum = testBuildOrNeighbour(
        options, 0, urlsTbox, buildType, testedIDs)
    if sID is None:
        raise Exception('No complete builds were found.')
    print 'Numeric ID ' + sID + ' was tested.'

    # Download and test ending point.
    print '\nExamining ending point...'
    eID, endResult, eReason, ePosition, urlsTbox, testedIDs, endSkippedNum = testBuildOrNeighbour(
        options, len(urlsTbox) - 1, urlsTbox, buildType, testedIDs)
    if eID is None:
        raise Exception('No complete builds were found.')
    print 'Numeric ID ' + eID + ' was tested.'

    if startResult == endResult:
        raise Exception('Starting and ending points should have opposite results')

    count = 0
    print '\nStarting bisection...\n'
    while count < MAX_ITERATIONS:
        sps.vdump('Unsorted dictionary of tested IDs is: ' + str(testedIDs))
        count += 1
        print 'Test number ' + str(count) + ':'

        sortedUrlsTbox = sorted(urlsTbox)
        if len(sortedUrlsTbox) >= 3:
            mPosition = len(sortedUrlsTbox) // 2
        else:
            print '\nWARNING: ' + str(sortedUrlsTbox) + ' has size smaller than 3. ' + \
                'Impossible to return "middle" element.\n'
            mPosition = len(sortedUrlsTbox)

        # Test the middle revision. If it is not a complete build, test ones around it.
        mID, mResult, mReason, mPosition, urlsTbox, testedIDs, middleRevSkippedNum = testBuildOrNeighbour(
            options, mPosition, urlsTbox, buildType, testedIDs)
        if mID is None:
            print 'Middle ID is None.'
            break

        # Refresh the range of treeherder IDs depending on mResult.
        if mResult == endResult:
            urlsTbox = urlsTbox[0:(mPosition + 1)]
        else:
            urlsTbox = urlsTbox[(mPosition):len(urlsTbox)]

        print 'Numeric ID ' + mID + ' was tested.',

        #  Exit infinite loop once we have tested the starting point, ending point and any points
        #  in the middle with results returning "incomplete".
        if (len(urlsTbox) - middleRevSkippedNum) <= 2 and mID in testedIDs:
            break
        elif len(urlsTbox) < 2:
            print 'urlsTbox is: ' + str(urlsTbox)
            raise Exception('Length of urlsTbox should not be smaller than 2.')
        elif (len(testedIDs) - 2) > 30:
            raise Exception('Number of testedIDs has exceeded 30.')

        print showRemainingNumOfTests(urlsTbox)

    print
    sps.vdump('Build URLs are: ' + str(urlsTbox))
    assert getIdFromTboxUrl(urlsTbox[0]) in testedIDs, 'Starting ID should have been tested.'
    assert getIdFromTboxUrl(urlsTbox[-1]) in testedIDs, 'Ending ID should have been tested.'
    outputTboxBisectionResults(options, urlsTbox, testedIDs)
Пример #5
0
def bisectUsingTboxBins(options):
    '''
    Downloads treeherder binaries and bisects them.
    '''
    testedIDs = {}
    desiredArch = '32' if options.buildOptions.enable32 else '64'
    buildType = downloadBuild.defaultBuildType(options.nameOfTreeherderBranch,
                                               desiredArch,
                                               options.buildOptions.enableDbg)

    # Get list of treeherder IDs
    urlsTbox = downloadBuild.getBuildList(buildType,
                                          earliestBuild=options.startRepo,
                                          latestBuild=options.endRepo)

    # Download and test starting point.
    print '\nExamining starting point...'
    sID, startResult, sReason, sPosition, urlsTbox, testedIDs = testBuildOrNeighbour(
        options, 0, urlsTbox, buildType, testedIDs)
    if sID is None:
        raise Exception('No complete builds were found.')
    print 'Numeric ID ' + sID + ' was tested.'

    # Download and test ending point.
    print '\nExamining ending point...'
    eID, endResult, eReason, ePosition, urlsTbox, testedIDs = testBuildOrNeighbour(
        options,
        len(urlsTbox) - 1, urlsTbox, buildType, testedIDs)
    if eID is None:
        raise Exception('No complete builds were found.')
    print 'Numeric ID ' + eID + ' was tested.'

    if startResult == endResult:
        raise Exception(
            'Starting and ending points should have opposite results')

    count = 0
    print '\nStarting bisection...\n'
    while count < MAX_ITERATIONS:
        sps.vdump('Unsorted dictionary of tested IDs is: ' + str(testedIDs))
        count += 1
        print 'Test number ' + str(count) + ':'

        sortedUrlsTbox = sorted(urlsTbox)
        if len(sortedUrlsTbox) >= 3:
            mPosition = len(sortedUrlsTbox) // 2
        else:
            print '\nWARNING: ' + str(sortedUrlsTbox) + ' has size smaller than 3. ' + \
                'Impossible to return "middle" element.\n'
            mPosition = len(sortedUrlsTbox)

        # Test the middle revision. If it is not a complete build, test ones around it.
        mID, mResult, mReason, mPosition, urlsTbox, testedIDs = testBuildOrNeighbour(
            options, mPosition, urlsTbox, buildType, testedIDs)
        if mID is None:
            print 'Middle ID is None.'
            break

        # Refresh the range of treeherder IDs depending on mResult.
        if mResult == endResult:
            urlsTbox = urlsTbox[0:(mPosition + 1)]
        else:
            urlsTbox = urlsTbox[(mPosition):len(urlsTbox)]

        print 'Numeric ID ' + mID + ' was tested.',

        # Exit infinite loop once we have tested both the starting point and the ending point.
        if len(urlsTbox) == 2 and mID in testedIDs:
            break
        elif len(urlsTbox) < 2:
            print 'urlsTbox is: ' + str(urlsTbox)
            raise Exception('Length of urlsTbox should not be smaller than 2.')
        elif (len(testedIDs) - 2) > 30:
            raise Exception('Number of testedIDs has exceeded 30.')

        print showRemainingNumOfTests(urlsTbox)

    print
    sps.vdump('Build URLs are: ' + str(urlsTbox))
    assert getIdFromTboxUrl(
        urlsTbox[0]) in testedIDs, 'Starting ID should have been tested.'
    assert getIdFromTboxUrl(
        urlsTbox[-1]) in testedIDs, 'Ending ID should have been tested.'
    outputTboxBisectionResults(options, urlsTbox, testedIDs)