diff options
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/buildbot-build.sh | 3 | ||||
| -rw-r--r-- | tools/cpp-define-generator/Android.bp | 13 | ||||
| -rwxr-xr-x | tools/cpp-define-generator/presubmit-check-files-up-to-date | 67 | ||||
| -rwxr-xr-x | tools/cpp-define-generator/verify-asm-support | 101 | ||||
| -rw-r--r-- | tools/dexfuzz/README | 2 | ||||
| -rwxr-xr-x | tools/jfuzz/run_dex_fuzz_test.py | 25 | ||||
| -rwxr-xr-x | tools/jfuzz/run_jfuzz_test_nightly.py | 31 |
7 files changed, 220 insertions, 22 deletions
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh index 2d26b4858d..963efa49a5 100755 --- a/tools/buildbot-build.sh +++ b/tools/buildbot-build.sh @@ -52,6 +52,9 @@ while true; do shift elif [[ "$1" == "" ]]; then break + else + echo "Unknown options $@" + exit 1 fi done diff --git a/tools/cpp-define-generator/Android.bp b/tools/cpp-define-generator/Android.bp index d792e906ef..59c52117eb 100644 --- a/tools/cpp-define-generator/Android.bp +++ b/tools/cpp-define-generator/Android.bp @@ -20,7 +20,7 @@ // // In the future we may wish to parameterize this on (32,64)x(read_barrier,no_read_barrier). -art_cc_binary { +cc_binary { // Do not use art_cc_binary because HOST_PREFER_32_BIT is incompatible with genrule. name: "cpp-define-generator-data", host_supported: true, device_supported: false, @@ -34,3 +34,14 @@ art_cc_binary { "libbase", ], } + +// Note: See $OUT_DIR/soong/build.ninja +// For the exact filename that this generates to run make command on just +// this rule later. +genrule { + name: "cpp-define-generator-asm-support", + out: ["asm_support_gen.h"], + tools: ["cpp-define-generator-data"], + tool_files: ["verify-asm-support"], + cmd: "$(location verify-asm-support) --quiet \"$(location cpp-define-generator-data)\" \"$(out)\"" +} diff --git a/tools/cpp-define-generator/presubmit-check-files-up-to-date b/tools/cpp-define-generator/presubmit-check-files-up-to-date new file mode 100755 index 0000000000..67a702adc7 --- /dev/null +++ b/tools/cpp-define-generator/presubmit-check-files-up-to-date @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# --------------------------------------------------------------------------- + +# Generates asm_support_gen.h into a temporary location. +# Then verifies it is the same as our local stored copy. + +GEN_TOOL=cpp-define-generator-data + +if ! which "$GEN_TOOL"; then + echo "ERROR: Please build cpp-define-generator-data or source build/envsetup.sh" >&2 + exit 1 +fi + +####################### +####################### + +PREUPLOAD_COMMIT_COPY="$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXX)" +BUILD_COPY="$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXX)" + +function finish() { + # Delete temp files. + [[ -f "$PREUPLOAD_COMMIT_COPY" ]] && rm "$PREUPLOAD_COMMIT_COPY" + [[ -f "$BUILD_COPY" ]] && rm "$BUILD_COPY" +} +trap finish EXIT + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ART_DIR="$( cd "$DIR/../.." && pwd )" +ASM_SUPPORT_GEN_CHECKED_IN_COPY="runtime/generated/asm_support_gen.h" + +# Repo upload hook runs inside of the top-level git directory. +# If we run this script manually, be in the right place for git. +cd "$ART_DIR" + +if [[ -z $PREUPLOAD_COMMIT ]]; then + echo "WARNING: Not running as a pre-upload hook. Assuming commit to check = 'HEAD'" + PREUPLOAD_COMMIT=HEAD +fi + +# Get version we are about to push into git. +git show "$PREUPLOAD_COMMIT:$ASM_SUPPORT_GEN_CHECKED_IN_COPY" > "$PREUPLOAD_COMMIT_COPY" || exit 1 +# Get version that our build would have made. +"$GEN_TOOL" > "$BUILD_COPY" || exit 1 + +if ! diff "$PREUPLOAD_COMMIT_COPY" "$BUILD_COPY"; then + echo "asm-support: ERROR: Checked-in copy of '$ASM_SUPPORT_GEN_CHECKED_IN_COPY' " >&2 + echo " has diverged from the build copy." >&2 + echo " Please re-run the 'generate-asm-support' command to resync the header." >&2 + exit 1 +fi + +# Success. Print nothing to avoid spamming users. diff --git a/tools/cpp-define-generator/verify-asm-support b/tools/cpp-define-generator/verify-asm-support new file mode 100755 index 0000000000..745b1153c9 --- /dev/null +++ b/tools/cpp-define-generator/verify-asm-support @@ -0,0 +1,101 @@ +#!/bin/bash +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# --------------------------------------------------------------------------- + +# Generates asm_support_gen.h into the $OUT directory in the build. +# Then verifies that it is the same as in runtime/generated/asm_support_gen.h + +# Validates that art/runtime/generated/asm_support_gen.h +# - This must be run after a build since it uses cpp-define-generator-data + +# Path to asm_support_gen.h that we check into our git repository. +ASM_SUPPORT_GEN_CHECKED_IN_COPY="runtime/generated/asm_support_gen.h" +# Instead of producing an error if checked-in copy differs from the generated version, +# overwrite the local checked-in copy instead. +OVERWRITE_CHECKED_IN_COPY_IF_CHANGED="n" + +####################### +####################### + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ART_DIR="$( cd "$DIR/../.." && pwd )" +ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY="$ART_DIR/runtime/generated/asm_support_gen.h" + +# Sanity check that we haven't moved the file around. +# If we did, perhaps the above constant should be updated. +if ! [[ -f "$ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY" ]]; then + echo "ERROR: Missing asm_support_gen.h, expected to be in '$ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY'" >&2 + exit 1 +fi + +# The absolute path to cpp-define-generator is in $1 +# Generate the file as part of the build into the out location specified by $2. + +# Compare that the generated file matches our golden copy that's checked into git. +# If not, it is a fatal error and the user needs to run 'generate-asm-support' to rebuild. + +if [[ $# -lt 2 ]]; then + echo "Usage: $0 [--quiet] [--presubmit] <path-to-cpp-define-generator-data-binary> <output-file>'" >&2 + exit 1 +fi + +# Supress 'chatty' messages during the build. +# If anything is printed in a success case then +# the main Android build can't reuse the same line for +# showing multiple commands being executed. +QUIET=false +if [[ "$1" == "--quiet" ]]; then + QUIET=true + shift +fi + +CPP_DEFINE_GENERATOR_TOOL="$1" +OUTPUT_FILE="$2" + +function pecho() { + if ! $QUIET; then + echo "$@" + fi +} + +# Generate the header. Print the command we're running to console for readability. +pecho "cpp-define-generator-data > \"$OUTPUT_FILE\"" +"$CPP_DEFINE_GENERATOR_TOOL" > "$OUTPUT_FILE" +retval="$?" + +if [[ $retval -ne 0 ]]; then + echo "verify-asm-support: FATAL: Error while running cpp-define-generator-data" >&2 + exit $retval +fi + +if ! diff "$ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY" "$OUTPUT_FILE"; then + + if [[ $OVERWRITE_CHECKED_IN_COPY_IF_CHANGED == "y" ]]; then + cp "$OUTPUT_FILE" "$ABS_ASM_SUPPORT_GEN_CHECKED_IN_COPY" + echo "verify-asm-support: OK: Overwrote '$ASM_SUPPORT_GEN_CHECKED_IN_COPY' with build copy." + echo " Please 'git add $ASM_SUPPORT_GEN_CHECKED_IN_COPY'." + else + echo "---------------------------------------------------------------------------------------------" >&2 + echo "verify-asm-support: ERROR: Checked-in copy of '$ASM_SUPPORT_GEN_CHECKED_IN_COPY' " >&2 + echo " has diverged from the build copy." >&2 + echo " Please re-run the 'generate-asm-support' command to resync the header." >&2 + [[ -f "$OUTPUT_FILE" ]] && rm "$OUTPUT_FILE" + exit 1 + fi +fi + +pecho "verify-asm-support: SUCCESS. Built '$OUTPUT_FILE' which matches our checked in copy." diff --git a/tools/dexfuzz/README b/tools/dexfuzz/README index c1cdf1e3f4..78f73f5c11 100644 --- a/tools/dexfuzz/README +++ b/tools/dexfuzz/README @@ -98,7 +98,7 @@ MutateFail - because mutation is a random process, and has attempt thresholds to Timed Out - mutated files that timed out for one or more backends. Current timeouts are: Optimizing - 5 seconds - Intepreter - 30 seconds + Interpreter - 30 seconds (use --short-timeouts to set all backends to 2 seconds.) Successful - mutated files that executed and all backends agreed on the resulting output. NB: if all backends crashed with the same output, this would diff --git a/tools/jfuzz/run_dex_fuzz_test.py b/tools/jfuzz/run_dex_fuzz_test.py index 50c4f20aa7..34a92f6ea8 100755 --- a/tools/jfuzz/run_dex_fuzz_test.py +++ b/tools/jfuzz/run_dex_fuzz_test.py @@ -19,7 +19,7 @@ import os import shutil import sys -from subprocess import check_call +from subprocess import call from tempfile import mkdtemp sys.path.append(os.path.dirname(os.path.dirname( @@ -75,6 +75,9 @@ class DexFuzzTester(object): top = GetEnvVariableOrError('ANDROID_BUILD_TOP') self._dexfuzz_env['PATH'] = (top + '/art/tools/bisection_search:' + self._dexfuzz_env['PATH']) + android_root = GetEnvVariableOrError('ANDROID_HOST_OUT') + self._dexfuzz_env['ANDROID_ROOT'] = android_root + self._dexfuzz_env['LD_LIBRARY_PATH'] = android_root + '/lib' os.chdir(self._dexfuzz_dir) os.mkdir('divergent_programs') os.mkdir('bisection_outputs') @@ -119,24 +122,30 @@ class DexFuzzTester(object): def RunDexFuzz(self): """Starts the DexFuzz testing.""" os.chdir(self._dexfuzz_dir) - dexfuzz_args = ['--inputs=' + self._inputs_dir, '--execute', - '--execute-class=Test', '--repeat=' + str(self._num_tests), - '--dump-output', '--interpreter', '--optimizing', + dexfuzz_args = ['--inputs=' + self._inputs_dir, + '--execute', + '--execute-class=Test', + '--repeat=' + str(self._num_tests), + '--dump-output', '--dump-verify', + '--interpreter', '--optimizing', '--bisection-search'] if self._device is not None: dexfuzz_args += ['--device=' + self._device, '--allarm'] else: dexfuzz_args += ['--host'] # Assume host otherwise. - check_call(['dexfuzz'] + dexfuzz_args, env=self._dexfuzz_env) - # TODO: summarize findings. + cmd = ['dexfuzz'] + dexfuzz_args + print('**** Running ****\n\n', cmd, '\n') + call(cmd, env=self._dexfuzz_env) + print('\n**** Results (report.log) ****\n') + call(['tail', '-n 24', 'report.log']) def main(): # Handle arguments. parser = argparse.ArgumentParser() - parser.add_argument('--num_tests', default=10000, + parser.add_argument('--num_tests', default=1000, type=int, help='number of tests to run') - parser.add_argument('--num_inputs', default=50, + parser.add_argument('--num_inputs', default=10, type=int, help='number of JFuzz program to generate') parser.add_argument('--device', help='target device serial number') args = parser.parse_args() diff --git a/tools/jfuzz/run_jfuzz_test_nightly.py b/tools/jfuzz/run_jfuzz_test_nightly.py index 29595f2886..a9f8365c8f 100755 --- a/tools/jfuzz/run_jfuzz_test_nightly.py +++ b/tools/jfuzz/run_jfuzz_test_nightly.py @@ -26,9 +26,6 @@ from glob import glob from tempfile import mkdtemp from tempfile import TemporaryFile -# Default arguments for run_jfuzz_test.py. -DEFAULT_ARGS = ['--num_tests=20000'] - # run_jfuzz_test.py success string. SUCCESS_STRING = 'success (no divergences)' @@ -36,17 +33,22 @@ SUCCESS_STRING = 'success (no divergences)' NOT_FOUND = -1 def main(argv): + # Set up. cwd = os.path.dirname(os.path.realpath(__file__)) - cmd = [cwd + '/run_jfuzz_test.py'] + DEFAULT_ARGS + cmd = [cwd + '/run_jfuzz_test.py'] parser = argparse.ArgumentParser() parser.add_argument('--num_proc', default=8, type=int, help='number of processes to run') # Unknown arguments are passed to run_jfuzz_test.py. (args, unknown_args) = parser.parse_known_args() + # Run processes. + cmd = cmd + unknown_args + print('\n**** Running ****\n\n', cmd, '\n') output_files = [TemporaryFile('wb+') for _ in range(args.num_proc)] processes = [] - for output_file in output_files: - processes.append(subprocess.Popen(cmd + unknown_args, stdout=output_file, + for i, output_file in enumerate(output_files): + print('Tester', i) + processes.append(subprocess.Popen(cmd, stdout=output_file, stderr=subprocess.STDOUT)) try: # Wait for processes to terminate. @@ -56,6 +58,7 @@ def main(argv): for proc in processes: proc.kill() # Output results. + print('\n**** Results ****\n') output_dirs = [] for i, output_file in enumerate(output_files): output_file.seek(0) @@ -65,20 +68,24 @@ def main(argv): directory_match = re.search(r'Directory[^:]*: ([^\n]+)\n', output_str) if directory_match: output_dirs.append(directory_match.group(1)) - print('Tester', i) if output_str.find(SUCCESS_STRING) == NOT_FOUND: - print(output_str) + print('Tester', i, output_str) else: - print(SUCCESS_STRING) + print('Tester', i, SUCCESS_STRING) # Gather divergences. global_out_dir = mkdtemp('jfuzz_nightly') - divergence_nr = 1 + divergence_nr = 0 for out_dir in output_dirs: for divergence_dir in glob(out_dir + '/divergence*/'): + divergence_nr += 1 shutil.copytree(divergence_dir, global_out_dir + '/divergence' + str(divergence_nr)) - divergence_nr += 1 - print('Global output directory:', global_out_dir) + if divergence_nr > 0: + print('\n!!!! Divergences !!!!', divergence_nr) + else: + print ('\nSuccess') + print('\nGlobal output directory:', global_out_dir) + print() if __name__ == '__main__': main(sys.argv) |