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 '\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)
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)