def directMain(): logPrefix = os.path.join(mkdtemp(prefix="domfuzz-rdf-main"), "t") print logPrefix collector = createCollector.createCollector("DOMFuzz") bc = BrowserConfig(sys.argv[1:], collector) if bc.options.argURL: extraPrefs = randomPrefs.grabExtraPrefs(bc.options.argURL) else: extraPrefs = "" br = BrowserResult(bc, bc.options.argURL or "about:blank", logPrefix, extraPrefs=extraPrefs, leaveProfile=True) print br.level if bc.options.submit: if br.level >= bc.options.minimumInterestingLevel: testcaseFilename = bc.options.argURL print "Submitting " + testcaseFilename quality = 0 collector.submit(br.crashInfo, testcaseFilename, quality) else: print "Not submitting (not interesting)" else: sys.exit(br.level)
def interesting(args, tempPrefix): global bcForLithium bc = bcForLithium url = bc.options.argURL extraPrefs = randomPrefs.grabExtraPrefs(url) # Re-scan testcase (and prefs file) in case Lithium changed them br = BrowserResult(bc, url, tempPrefix, extraPrefs=extraPrefs) return br.level >= bc.options.minimumInterestingLevel
def interesting(args, tempPrefix): global levelAndLinesForLithium, deleteProfileForLithium, minimumInterestingLevel, lithiumURL, extraPrefsForLithium extraPrefs = randomPrefs.grabExtraPrefs( lithiumURL ) # Re-scan testcase (and prefs file) in case Lithium changed them actualLevel, lines = levelAndLinesForLithium(lithiumURL, logPrefix=tempPrefix, extraPrefs=extraPrefs) return actualLevel >= minimumInterestingLevel
def directMain(): logPrefix = os.path.join(mkdtemp(prefix="domfuzz-rdf-main"), "t") print logPrefix levelAndLines, options = rdfInit(sys.argv[1:]) if options.argURL: extraPrefs = randomPrefs.grabExtraPrefs(options.argURL) else: extraPrefs = "" level, lines = levelAndLines(options.argURL or "about:blank", logPrefix, extraPrefs=extraPrefs, leaveProfile=True) print level sys.exit(level)
def interesting(args, tempPrefix): global levelAndLinesForLithium, deleteProfileForLithium, minimumInterestingLevel, lithiumURL, extraPrefsForLithium extraPrefs = randomPrefs.grabExtraPrefs(lithiumURL) # Re-scan testcase (and prefs file) in case Lithium changed them actualLevel, lines = levelAndLinesForLithium(lithiumURL, logPrefix=tempPrefix, extraPrefs=extraPrefs) return actualLevel >= minimumInterestingLevel
def retestAll(): ''' Retest all testcases in retestRoot, starting with the newest, without modifying that subtree (because it might be rsync'ed). ''' testcases = [] retestSkips = readSkips(skips) # Find testcases to retest for jobTypeDir in (os.path.join(retestRoot, x) for x in os.listdir(retestRoot) if x.startswith("dom" + "-")): if "mac" not in jobTypeDir: continue # XXX just for now for j in os.listdir(jobTypeDir): if "-asan" in buildDir and "-asan" not in jobTypeDir: pass # what's going on here??? elif j.split("_")[0] in retestSkips: print "Skipping " + j + " for " + j.split("_")[0] elif "_0_lines" in j: print "Skipping a 0-line testcase" elif "_reduced" in j: job = os.path.join(jobTypeDir, j) testcase_leafs = filter(lambda s: s.find("reduced") != -1, os.listdir(job)) if len(testcase_leafs) == 1: testcase = os.path.join(job, testcase_leafs[0]) mtime = os.stat(testcase).st_mtime testcases.append({'testcase': testcase, 'mtime': mtime}) # Sort so the newest testcases are first print "Retesting " + str(len(testcases)) + " testcases..." testcases.sort(key=lambda t: t['mtime'], reverse=True) i = 0 bc = domInteresting.BrowserConfig( ["--background", buildDir], domInteresting.createCollector.createCollector("DOMFuzz")) tempDir = tempfile.mkdtemp("retesting") # Retest all the things! for t in testcases: testcase = t['testcase'] print testcase i += 1 logPrefix = os.path.join(tempDir, str(i)) extraPrefs = randomPrefs.grabExtraPrefs(testcase) testcaseURL = loopdomfuzz.asFileURL(testcase) domresult = domInteresting.BrowserResult(bc, testcaseURL, logPrefix, extraPrefs=extraPrefs, quiet=True) #if level > domInteresting.DOM_FINE: # print "Reproduced: " + testcase # with open(logPrefix + "-summary.txt") as f: # for line in f: # print line, # Would it be easier to do it this way? #with open(os.devnull, "w") as devnull: # p = subprocess.Popen([loopdomfuzz.domInterestingpy, "mozilla-central/obj-firefox-asan-debug/", testcase], stdout=devnull, stderr=subprocess.STDOUT) # if p.wait() > 0: # print "Still reproduces: " + testcase # Ideally we'd use something like "lithium-command.txt" to get the right --valgrind args, etc... # (but we don't want the --min-level option) # Or this way? #lithArgs = ["--strategy=check-only", loopdomfuzz.domInterestingpy, buildInfo.buildDir, testcase] # #(lithResult, lithDetails) = lithOps.runLithium(lithArgs, logPrefix, options.targetTime) #if lithResult == lithOps.LITH_RETESTED_STILL_INTERESTING: # print "Reproduced: " + testcase shutil.rmtree(tempDir)
def retestAll(options, buildInfo): ''' Retest all testcases in options.retestRoot, starting with the newest, without modifying that subtree (because it might be rsync'ed). ''' assert options.testType == "dom" testcases = [] retestSkips = readSkips(options.retestSkips) # Find testcases to retest for jobTypeDir in (os.path.join(options.retestRoot, x) for x in os.listdir(options.retestRoot) if x.startswith(options.testType + "-")): for j in os.listdir(jobTypeDir): if "-asan" in buildInfo.buildDir and "-asan" not in jobTypeDir: pass elif j.split("_")[0] in retestSkips: print "Skipping " + j + " for " + j.split("_")[0] elif "_0_lines" in j: print "Skipping a 0-line testcase" elif "_reduced" in j: job = os.path.join(jobTypeDir, j) testcase_leafs = filter(lambda s: s.find("reduced") != -1, os.listdir(job)) if len(testcase_leafs) == 1: testcase = os.path.join(job, testcase_leafs[0]) mtime = os.stat(testcase).st_mtime testcases.append({'testcase': testcase, 'mtime': mtime}) # Sort so the newest testcases are first print "Retesting " + str(len(testcases)) + " testcases..." testcases.sort(key=lambda t: t['mtime'], reverse=True) i = 0 levelAndLines, domInterestingOptions = domInteresting.rdfInit([buildInfo.buildDir]) tempDir = tempfile.mkdtemp("retesting") # Retest all the things! for t in testcases: testcase = t['testcase'] print testcase i += 1 logPrefix = os.path.join(tempDir, str(i)) extraPrefs = randomPrefs.grabExtraPrefs(testcase) testcaseURL = loopdomfuzz.asFileURL(testcase) level, lines = levelAndLines(testcaseURL, logPrefix=logPrefix, extraPrefs=extraPrefs, quiet=True) #if level > domInteresting.DOM_FINE: # print "Reproduced: " + testcase # with open(logPrefix + "-summary.txt") as f: # for line in f: # print line, # Would it be easier to do it this way? #with open(os.devnull, "w") as devnull: # p = subprocess.Popen([loopdomfuzz.domInterestingpy, "mozilla-central/obj-firefox-asan-debug/", testcase], stdout=devnull, stderr=subprocess.STDOUT) # if p.wait() > 0: # print "Still reproduces: " + testcase # Ideally we'd use something like "lithium-command.txt" to get the right --valgrind args, etc... # (but we don't want the --min-level option) # Or this way? #lithArgs = ["--strategy=check-only", loopdomfuzz.domInterestingpy, buildInfo.buildDir, testcase] # #(lithResult, lithDetails) = lithOps.runLithium(lithArgs, logPrefix, options.targetTime) #if lithResult == lithOps.LITH_RETESTED_STILL_INTERESTING: # print "Reproduced: " + testcase shutil.rmtree(tempDir)