Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
590c8fb
Refactor code involving resource import to not rely on os.name
nth10sd May 9, 2018
d0c7989
Replace various os/os.path usages with pathlib2/pathlib.
nth10sd Apr 20, 2018
42865b6
Ignore pylint "no-member" false positive error for now.
nth10sd May 9, 2018
19536ce
Fix #23 - Remove captureStdout and use subprocess32/subprocess from P…
nth10sd May 12, 2018
0f3ada0
Remove getAbsPathForAdjacentFile and normExpUserPath.
nth10sd May 12, 2018
38db227
Remove unused imports.
nth10sd May 12, 2018
c7da692
subprocess-related follow-up fix.
nth10sd May 12, 2018
a48cfa5
pathlib-related follow-up fix.
nth10sd May 12, 2018
7bf932f
Ignore more pylint "no-member" false positives.
nth10sd May 12, 2018
934bdb4
Add comment related to is_win_dumping_to_default raising WindowsError…
nth10sd May 25, 2018
4bf7c1f
Merge branch 'master' into pathlib-usage
nth10sd May 25, 2018
e1f9bd9
In Python 3, winreg functions usually throw OSError instead of Window…
nth10sd May 25, 2018
9d49f0f
Oops, WindowsError is a subclass of OSError.
nth10sd May 25, 2018
c1dc85a
Merge branch 'master' into pathlib-usage
nth10sd May 26, 2018
de4d398
Revert "Ignore more pylint "no-member" false positives."
nth10sd May 26, 2018
8e02d4e
Revert "Ignore pylint "no-member" false positive error for now."
nth10sd May 26, 2018
f521964
Remove last no-member ignore line false-positive.
nth10sd May 26, 2018
8ac20e6
Merge branch 'master' into pathlib-usage
nth10sd May 26, 2018
6cd315f
Merge branch 'master' into pathlib-usage
nth10sd May 26, 2018
7e9a7d9
Continue to ignore no-member pylint errors until newer linter librari…
nth10sd May 26, 2018
9ccc030
Inline scanLine function, then move last detect_malloc_errors functio…
nth10sd Apr 10, 2018
9a1c70b
Replace logPrefix file-renaming and suffix-changing with the proper p…
nth10sd May 26, 2018
3340b2c
Deal with .fuzzmanagerconf files using pathlib.
nth10sd May 26, 2018
c113499
Convert Paths to make them Lithium-friendly.
nth10sd May 26, 2018
840c7bb
Check file sizes in truncateFile using the pathlib way.
nth10sd May 26, 2018
578a0e6
More pathlib fixes.
nth10sd May 26, 2018
bde71eb
We should assert the existence of the concatenated jsfunfuzz file a l…
nth10sd May 26, 2018
a9533be
Rename the autoBisectLogFilename and autoBisectLog variables.
nth10sd May 26, 2018
60199af
Make handle_rm_readonly Windows-only for simplification since we only…
nth10sd May 26, 2018
5d0fc34
Remove superfluous __name__/__main__ line in bot.py
nth10sd May 26, 2018
cbf2ba6
Python 3 only allows binary mode when using open() with buffering=0 set.
nth10sd May 26, 2018
2043c32
Use the parent/stem/suffix model of pathlib in more places.
nth10sd May 26, 2018
ae2ec0a
Make runthis retain its Path components and only convert to string wh…
nth10sd May 26, 2018
69f2ce8
Make quote usage first convert items to strings.
nth10sd May 26, 2018
dfdf7cd
Replace the filenameToReduce variable name with reduced_log.
nth10sd May 26, 2018
6a152a0
Force shutil usages to operate on strings.
nth10sd May 26, 2018
f9ae532
Rename _ to branch.
nth10sd May 29, 2018
4565450
Follow-up fix.
nth10sd May 30, 2018
9837942
Whitespace fixes.
nth10sd May 30, 2018
6e3de9f
Fix/remove invalid comments as indicated during review.
nth10sd May 31, 2018
a45f78e
Remove more comments.
nth10sd May 31, 2018
cadb5e6
Stop using range and use enumerate instead as suggested in review.
nth10sd May 31, 2018
999f702
More pathlib fixes.
nth10sd May 31, 2018
e926b7b
Remove bad line.
nth10sd May 31, 2018
241f703
Fix pathlib issue related to get_shell_cache_js_bin_path.
nth10sd May 31, 2018
0adf807
Yet more pathlib fixes.
nth10sd May 31, 2018
3d24175
Comment and whitespace changes.
nth10sd May 31, 2018
9f87bb9
Refactor getCfgCmdExclEnv to get_cfg_cmd_excl_env and setCfgCmdExclEn…
nth10sd May 31, 2018
32e23c8
self.cfg should be instantiated as a list in compile_shell.
nth10sd May 31, 2018
7d4e0d3
Add a docstring for CompiledShell class.
nth10sd May 31, 2018
e6aca2d
Inline updateRepo and remove the function.
nth10sd May 31, 2018
a8aaf2e
fork_join tests should become actual tests for pytest, commenting the…
nth10sd May 31, 2018
b017d9d
Make a tempfile import top-level and use the backports.tempfile versi…
nth10sd May 31, 2018
1eddcfc
Remove unneeded 'if __name__ == "__main__":' lines.
nth10sd May 31, 2018
58347b5
Remove unneeded imports from loop.py
nth10sd May 31, 2018
d19d283
Consolidate subprocess32 import with others in compare_jit.py
nth10sd May 31, 2018
b916d99
Rename printMachineInfo to print_machine_info and refactor it a little.
nth10sd May 31, 2018
4b5327c
Merge branch 'master' into pathlib-usage
nth10sd May 31, 2018
598aa3e
Defend against logPrefix not being a Path, e.g. when Lithium uses it,…
nth10sd Jun 1, 2018
a6e704e
Rename tempPrefix to cwd_prefix.
nth10sd Jun 1, 2018
dc57814
Make cwd_prefix explicit in using Path.cwd() when it is used.
nth10sd Jun 1, 2018
c96dba7
Convert remaining subprocess calls to use subprocess.run() instead.
nth10sd Jun 1, 2018
851227e
Refactor getEnvAdded to get_env_added and setEnvAdded to set_env_added.
nth10sd Jun 1, 2018
e35ba2d
Fix potential issue in get_shell_compiled_runlibs_path.
nth10sd Jun 1, 2018
341a7d0
We must call Path on a path, not potentially a symlink.
nth10sd Jun 1, 2018
6174041
Add tests for autoconf_run and ensure_cache_dir.
nth10sd Jun 1, 2018
31ca67c
More documentation for functions in the CompiledShell class.
nth10sd Jun 1, 2018
55243dd
Add more documentation for compare_jit function in compare_jit.
nth10sd Jun 1, 2018
cf5230a
Fix missing imports.
nth10sd Jun 1, 2018
067849d
Remove obsolete pylint ignore line.
nth10sd Jun 1, 2018
bec0461
Re-add some pylint ignores for the compare_jit function.
nth10sd Jun 1, 2018
271eef8
Refactor ignoreSomeOfStderr to ignore_some_stderr and fix pylint issues.
nth10sd Jun 1, 2018
580ef83
Remove print_function from files that do not have any print functions.
nth10sd Apr 19, 2018
f8ddf14
Add unicode_literals to the future import line of all files.
nth10sd Apr 19, 2018
5a39f38
Refactor getS3TarballWithExt to get_s3_tar_name_with_ext.
nth10sd Jun 1, 2018
cc5611a
Refactor getEnvFull to get_env_full and setEnvFull to set_env_full.
nth10sd Jun 1, 2018
999b741
Refactor getRepoName to get_repo_name.
nth10sd Jun 1, 2018
931a3ae
getMajorVersion and setMajorVersion seem unnecessary since they are j…
nth10sd Jun 1, 2018
eed1e63
Refactor getVersion to get_version and setVersion to set_version.
nth10sd Jun 1, 2018
7e1eaaf
Fix str/unicode confusion in repos_update.
nth10sd Jun 1, 2018
a760352
WIP: Add some FIXME comments, they really should be fixed.
nth10sd Mar 17, 2018
214340c
Fix pylint errors in test_autoconf_run.
nth10sd Jun 2, 2018
b8ea648
Fix the test_ensure_cache_dir test.
nth10sd Jun 2, 2018
7cf377c
Remove extra whitespace.
nth10sd Jun 2, 2018
8c418a4
Split off some helper functions from compile_shell.py into sm_compile…
nth10sd Jun 2, 2018
8d9e386
Inline code involving version in compile_shell.
nth10sd Jun 2, 2018
8ec1a8c
Mostly stop catching generic Exceptions in compile_shell.
nth10sd Jun 2, 2018
2094280
Refactor compileJs to sm_compile and fix previous WIP/FIXME items.
nth10sd Jun 2, 2018
57debe1
Fix more issues involving the move of functions to sm_compile_helpers.
nth10sd Jun 2, 2018
fc3cb9e
Use io.open instead of open throughout.
nth10sd Jun 2, 2018
5cc6a2e
Fix encoding issues with io.open
nth10sd Jun 2, 2018
e3fa763
Remove unneeded parenthesis.
nth10sd Jun 2, 2018
6e8a0f2
Fix more encoding issues with io.open in tests.
nth10sd Jun 2, 2018
2632e9e
Binary mode of io.open does not take an encoding argument.
nth10sd Jun 2, 2018
74bc091
Fix another encoding issue.
nth10sd Jun 2, 2018
4906b1b
Lithium only takes in strings, not Paths nor bytes.
nth10sd Jun 2, 2018
0715ae8
SyntaxError fix.
nth10sd Jun 2, 2018
7dc93cc
Revert "Remove unneeded 'if __name__ == "__main__":' lines."
nth10sd Jun 2, 2018
6681927
Cast more paths to strings before decoding them.
nth10sd Jun 2, 2018
2cd117c
Most repo_dirs are now Paths.
nth10sd Jun 2, 2018
480c25d
Fix missing imports.
nth10sd Jun 2, 2018
5c90b83
Improve dual Python 2/3 code.
nth10sd Jun 2, 2018
387d8c7
knownPath is still present so account for it for now.
nth10sd Jun 2, 2018
ffb33e6
Yet another pathlib issue.
nth10sd Jun 2, 2018
5448495
Ensure that cwd_prefix is a Path in js_interesting.
nth10sd Jun 2, 2018
b5db2ac
Collector takes in strings, not Paths.
nth10sd Jun 2, 2018
8a281ee
Expand the repo_dir path first, in build_options.
nth10sd Jun 2, 2018
5529beb
Add an unrelated pylint ignore line.
nth10sd Jun 2, 2018
73adceb
Run Paths in the parsing function of compare_jit through .expanduser(…
nth10sd Jun 2, 2018
b61466d
Raise an OSError if a file does not exist in the parsing function of …
nth10sd Jun 2, 2018
a676d8e
Ensure cwd_prefix is a Path in compare_jit.
nth10sd Jun 2, 2018
59644e5
When running compare_jit standalone, ensure the temp folder that is c…
nth10sd Jun 2, 2018
c806081
Path does not care that it is already working on a Path instance.
nth10sd Jun 2, 2018
6e61ad1
Make sure also to run pathToBinary through .expanduser()
nth10sd Jun 2, 2018
79eb6a9
Add more pylint ignore lines to suit PyPy3.
nth10sd Jun 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 101 additions & 58 deletions src/funfuzz/autobisectjs/autobisectjs.py

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/funfuzz/autobisectjs/known_broken_earliest_working.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""Known broken changeset ranges of SpiderMonkey are specified in this file.
"""

from __future__ import absolute_import, print_function # isort:skip
from __future__ import absolute_import, unicode_literals # isort:skip

import os
import platform
Expand Down Expand Up @@ -129,7 +129,8 @@ def earliest_known_working_rev(options, flags, skip_revs): # pylint: disable=mi
# Note that the sed version check only works with GNU sed, not BSD sed found in macOS.
if (platform.system() == "Linux" and
parse_version(subprocess.run(["sed", "--version"],
stdout=subprocess.PIPE).stdout.split()[3]) >= parse_version("4.3")):
stdout=subprocess.PIPE).stdout.decode("utf-8", errors="replace").split()[3])
>= parse_version("4.3")):
required.append("ebcbf47a83e7") # m-c 328765 Fx53, 1st w/ working builds using sed 4.3+ found on Ubuntu 17.04+
if options.disableProfiling:
required.append("800a887c705e") # m-c 324836 Fx53, 1st w/ --disable-profiling, see bug 1321065
Expand Down
83 changes: 44 additions & 39 deletions src/funfuzz/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

"""

from __future__ import absolute_import, division, print_function # isort:skip
from __future__ import absolute_import, division, print_function, unicode_literals # isort:skip

from builtins import object # pylint: disable=redefined-builtin
import io
import multiprocessing
from optparse import OptionParser # pylint: disable=deprecated-module
import os
Expand All @@ -20,19 +21,26 @@
import tempfile
import time

from whichcraft import which

from .js import build_options
from .js import compile_shell
from .js import loop
from .util import create_collector
from .util import fork_join
from .util import hg_helpers
from .util import subprocesses as sps
from .util import sm_compile_helpers
from .util.lock_dir import LockDir

if sys.version_info.major == 2:
from pathlib2 import Path
import psutil
if os.name == "posix":
import subprocess32 as subprocess # pylint: disable=import-error
else:
import subprocess
from pathlib import Path # pylint: disable=import-error

path0 = os.path.dirname(os.path.abspath(__file__)) # pylint: disable=invalid-name
JS_SHELL_DEFAULT_TIMEOUT = 24 # see comments in loop for tradeoffs


Expand Down Expand Up @@ -84,7 +92,8 @@ def parseOpts(): # pylint: disable=invalid-name,missing-docstring,missing-retur
if args:
print("Warning: bot does not use positional arguments")

if not options.useTreeherderBuilds and not os.path.isdir(build_options.DEFAULT_TREES_LOCATION):
# pylint: disable=no-member
if not options.useTreeherderBuilds and not build_options.DEFAULT_TREES_LOCATION.is_dir():
# We don't have trees, so we must use treeherder builds.
options.useTreeherderBuilds = True
print()
Expand All @@ -102,11 +111,11 @@ def parseOpts(): # pylint: disable=invalid-name,missing-docstring,missing-retur


def main(): # pylint: disable=missing-docstring
printMachineInfo()
print_machine_info()

options = parseOpts()

collector = create_collector.createCollector("jsfunfuzz")
collector = create_collector.make_collector()
try:
collector.refresh()
except RuntimeError as ex:
Expand All @@ -118,10 +127,10 @@ def main(): # pylint: disable=missing-docstring
print(options.tempDir)

build_info = ensureBuild(options)
assert os.path.isdir(build_info.buildDir)
assert build_info.buildDir.is_dir()

number_of_processes = multiprocessing.cpu_count()
if "-asan" in build_info.buildDir:
if "-asan" in str(build_info.buildDir):
# This should really be based on the amount of RAM available, but I don't know how to compute that in Python.
# I could guess 1 GB RAM per core, but that wanders into sketchyville.
number_of_processes = max(number_of_processes // 2, 1)
Expand All @@ -131,41 +140,41 @@ def main(): # pylint: disable=missing-docstring
shutil.rmtree(options.tempDir)


def printMachineInfo(): # pylint: disable=invalid-name
def print_machine_info():
"""Log information about the machine."""
print("Platform details: %s" % " ".join(platform.uname()))
print("hg version: %s" % sps.captureStdout(["hg", "-q", "version"])[0])

# In here temporarily to see if mock Linux slaves on TBPL have gdb installed
try:
print("gdb version: %s" % sps.captureStdout(["gdb", "--version"], combineStderr=True,
ignoreStderr=True, ignoreExitCode=True)[0])
except (KeyboardInterrupt, Exception) as ex: # pylint: disable=broad-except
print("Error involving gdb is: %r" % (ex,))

# FIXME: Should have if os.path.exists(path to git) or something # pylint: disable=fixme
# print("git version: %s" % sps.captureStdout(["git", "--version"], combineStderr=True,
# ignoreStderr=True, ignoreExitCode=True)[0])
print("hg info: %s" % subprocess.run(["hg", "-q", "version"], check=True, stdout=subprocess.PIPE).stdout.rstrip())
if which("gdb"):
gdb_version = subprocess.run(["gdb", "--version"],
stdout=subprocess.PIPE).stdout.decode("utf-8", errors="replace")
print("gdb info: %s" % gdb_version.split("\n")[0])
if which("git"):
print("git info: %s" % subprocess.run(["git", "version"], check=True, stdout=subprocess.PIPE).stdout.rstrip())
print("Python version: %s" % sys.version.split()[0])

print("Number of cores visible to OS: %d" % multiprocessing.cpu_count())
if sys.version_info.major == 2:
rootdir_free_space = psutil.disk_usage("/").free / (1024 ** 3)
else:
rootdir_free_space = shutil.disk_usage("/").free / (1024 ** 3) # pylint: disable=no-member
print("Free space (GB): %.2f" % rootdir_free_space)

hgrc_path = os.path.join(path0, ".hg", "hgrc")
if os.path.isfile(hgrc_path):
hgrc_path = Path("~/.hg/hgrc").expanduser()
if hgrc_path.is_file():
print("The hgrc of this repository is:")
with open(hgrc_path, "r") as f:
with io.open(str(hgrc_path), "r", encoding="utf-8", errors="replace") as f:
hgrc_contents = f.readlines()
for line in hgrc_contents:
print(line.rstrip())

if os.name == "posix":
try:
# resource library is only applicable to Linux or Mac platforms.
import resource # pylint: disable=import-error
# pylint: disable=no-member
print("Corefile size (soft limit, hard limit) is: %r" % (resource.getrlimit(resource.RLIMIT_CORE),))
except ImportError:
print("Not checking corefile size as resource module is unavailable")


def ensureBuild(options): # pylint: disable=invalid-name,missing-docstring,missing-return-doc,missing-return-type-doc
Expand All @@ -177,16 +186,16 @@ def ensureBuild(options): # pylint: disable=invalid-name,missing-docstring,miss
bRev = "" # pylint: disable=invalid-name
manyTimedRunArgs = [] # pylint: disable=invalid-name
elif not options.useTreeherderBuilds:
options.build_options = build_options.parseShellOptions(options.build_options)
options.build_options = build_options.parse_shell_opts(options.build_options)
options.timeout = options.timeout or (300 if options.build_options.runWithVg else JS_SHELL_DEFAULT_TIMEOUT)

with LockDir(compile_shell.getLockDirPath(options.build_options.repoDir)):
bRev = hg_helpers.getRepoHashAndId(options.build_options.repoDir)[0] # pylint: disable=invalid-name
with LockDir(sm_compile_helpers.get_lock_dir_path(Path.home(), options.build_options.repo_dir)):
bRev = hg_helpers.get_repo_hash_and_id(options.build_options.repo_dir)[0] # pylint: disable=invalid-name
cshell = compile_shell.CompiledShell(options.build_options, bRev)
updateLatestTxt = (options.build_options.repoDir == "mozilla-central") # pylint: disable=invalid-name
updateLatestTxt = (options.build_options.repo_dir == "mozilla-central") # pylint: disable=invalid-name
compile_shell.obtainShell(cshell, updateLatestTxt=updateLatestTxt)

bDir = cshell.getShellCacheDir() # pylint: disable=invalid-name
bDir = cshell.get_shell_cache_dir() # pylint: disable=invalid-name
# Strip out first 3 chars or else the dir name in fuzzing jobs becomes:
# js-js-dbg-opt-64-dm-linux
bType = build_options.computeShellType(options.build_options)[3:] # pylint: disable=invalid-name
Expand All @@ -199,9 +208,9 @@ def ensureBuild(options): # pylint: disable=invalid-name,missing-docstring,miss
"==============================================\n\n" % (
"funfuzz.js.compile_shell",
options.build_options.build_options_str,
options.build_options.repoDir,
options.build_options.repo_dir,
bRev,
cshell.getRepoName(),
cshell.get_repo_name(),
time.asctime()
))

Expand All @@ -216,15 +225,15 @@ def ensureBuild(options): # pylint: disable=invalid-name,missing-docstring,miss


def loopFuzzingAndReduction(options, buildInfo, collector, i): # pylint: disable=invalid-name,missing-docstring
tempDir = tempfile.mkdtemp("loop" + str(i)) # pylint: disable=invalid-name
tempDir = Path(tempfile.mkdtemp("loop" + str(i))) # pylint: disable=invalid-name
loop.many_timed_runs(options.targetTime, tempDir, buildInfo.mtrArgs, collector)


def mtrArgsCreation(options, cshell): # pylint: disable=invalid-name,missing-param-doc,missing-return-doc
# pylint: disable=missing-return-type-doc,missing-type-doc
"""Create many_timed_run arguments for compiled builds."""
manyTimedRunArgs = [] # pylint: disable=invalid-name
manyTimedRunArgs.append("--repo=" + sps.normExpUserPath(options.build_options.repoDir))
manyTimedRunArgs.append("--repo=%s" % options.build_options.repo_dir)
manyTimedRunArgs.append("--build=" + options.build_options.build_options_str)
if options.build_options.runWithVg:
manyTimedRunArgs.append("--valgrind")
Expand All @@ -236,10 +245,6 @@ def mtrArgsCreation(options, cshell): # pylint: disable=invalid-name,missing-pa

# Ordering of elements in manyTimedRunArgs is important.
manyTimedRunArgs.append(str(options.timeout))
manyTimedRunArgs.append(cshell.getRepoName()) # known bugs' directory
manyTimedRunArgs.append(cshell.getShellCacheFullPath())
manyTimedRunArgs.append(cshell.get_repo_name()) # known bugs' directory
manyTimedRunArgs.append(cshell.get_shell_cache_js_bin_path())
return manyTimedRunArgs


if __name__ == "__main__":
main()
10 changes: 8 additions & 2 deletions src/funfuzz/ccoverage/get_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@

import io
import logging
import os
import sys
import tarfile
import zipfile

import requests

if sys.version_info.major == 2:
from pathlib2 import Path
else:
from pathlib import Path # pylint: disable=import-error

RUN_COV_LOG = logging.getLogger("funfuzz")


Expand All @@ -41,7 +46,8 @@ def get_coverage_build(dirpath, args):

js_cov_bin_name = "js"
js_cov_bin = extract_folder / "dist" / "bin" / js_cov_bin_name
os.chmod(str(js_cov_bin), os.stat(str(js_cov_bin)).st_mode | 0o111) # Ensure the js binary is executable

Path.chmod(js_cov_bin, Path.stat(js_cov_bin).st_mode | 0o111) # Ensure the js binary is executable
assert js_cov_bin.is_file()

# Check that the binary is non-debug.
Expand Down
1 change: 1 addition & 0 deletions src/funfuzz/js/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
from . import compile_shell
from . import inspect_shell
from . import js_interesting
from . import link_fuzzer
from . import loop
from . import shell_flags
Loading