diff options
author | Martin Thomson <martin.thomson@gmail.com> | 2016-12-01 09:51:38 +0100 |
---|---|---|
committer | Martin Thomson <martin.thomson@gmail.com> | 2016-12-01 09:51:38 +0100 |
commit | cf80c95714a05dad08b05ce14e19941b7a893ae8 (patch) | |
tree | b6b3a0293472a665922d81587c1e26c36cc7120a | |
parent | cc2e43202159c30df0cd11a4a5b1bf2457e23a85 (diff) | |
download | nss-hg-cf80c95714a05dad08b05ce14e19941b7a893ae8.tar.gz |
Bug 1321438 - Copy repositories more comprehensively, r=ttaubert
Differential Revision: https://nss-review.dev.mozaws.net/D113
-rwxr-xr-x | fuzz/clone_corpus.sh | 11 | ||||
-rwxr-xr-x | fuzz/clone_libfuzzer.sh | 11 | ||||
-rw-r--r-- | fuzz/fuzz.gyp | 35 | ||||
-rwxr-xr-x | fuzz/git-copy.sh | 32 | ||||
-rw-r--r-- | fuzz/libFuzzer/libFuzzer.gyp | 43 |
5 files changed, 70 insertions, 62 deletions
diff --git a/fuzz/clone_corpus.sh b/fuzz/clone_corpus.sh index 55707f06d..a41cbc0c5 100755 --- a/fuzz/clone_corpus.sh +++ b/fuzz/clone_corpus.sh @@ -1,11 +1,4 @@ #!/bin/sh -cd $(dirname $0) - -mkdir tmp/ -git clone --no-checkout --depth 1 https://github.com/mozilla/nss-fuzzing-corpus tmp/ -(cd tmp && git reset --hard master) - -mkdir -p corpus -cp -r tmp/* corpus -rm -Rf tmp/ +d=$(dirname $0) +exec $d/git-copy.sh https://github.com/mozilla/nss-fuzzing-corpus master $d/corpus diff --git a/fuzz/clone_libfuzzer.sh b/fuzz/clone_libfuzzer.sh index e7298b8a7..91c93de31 100755 --- a/fuzz/clone_libfuzzer.sh +++ b/fuzz/clone_libfuzzer.sh @@ -1,11 +1,4 @@ #!/bin/sh -cd $(dirname $0) - -mkdir tmp/ -git clone --no-checkout --depth 1 https://chromium.googlesource.com/chromium/llvm-project/llvm/lib/Fuzzer tmp/ -(cd tmp && git reset --hard 1b543d6e5073b56be214394890c9193979a3d7e1) - -mkdir -p libFuzzer -cp tmp/*.cpp tmp/*.h tmp/*.def libFuzzer -rm -Rf tmp/ +d=$(dirname $0) +exec $d/git-copy.sh https://chromium.googlesource.com/chromium/llvm-project/llvm/lib/Fuzzer 1b543d6e5073b56be214394890c9193979a3d7e1 $d/libFuzzer diff --git a/fuzz/fuzz.gyp b/fuzz/fuzz.gyp index d8b48d38e..64befd0f8 100644 --- a/fuzz/fuzz.gyp +++ b/fuzz/fuzz.gyp @@ -8,6 +8,39 @@ ], 'targets': [ { + 'target_name': 'libFuzzer', + 'type': 'static_library', + 'sources': [ + 'libFuzzer/FuzzerCrossOver.cpp', + 'libFuzzer/FuzzerDriver.cpp', + 'libFuzzer/FuzzerExtFunctionsDlsym.cpp', + 'libFuzzer/FuzzerExtFunctionsWeak.cpp', + 'libFuzzer/FuzzerIO.cpp', + 'libFuzzer/FuzzerLoop.cpp', + 'libFuzzer/FuzzerMutate.cpp', + 'libFuzzer/FuzzerSHA1.cpp', + 'libFuzzer/FuzzerTracePC.cpp', + 'libFuzzer/FuzzerTraceState.cpp', + 'libFuzzer/FuzzerUtil.cpp', + 'libFuzzer/FuzzerUtilDarwin.cpp', + 'libFuzzer/FuzzerUtilLinux.cpp', + ], + 'cflags': [ + '-O2', + ], + 'cflags/': [ + ['exclude', '-fsanitize='], + ['exclude', '-fsanitize-'], + ], + 'xcode_settings': { + 'GCC_OPTIMIZATION_LEVEL': '2', # -O2 + 'OTHER_CFLAGS/': [ + ['exclude', '-fsanitize='], + ['exclude', '-fsanitize-'], + ], + }, + }, + { 'target_name': 'nssfuzz', 'type': 'executable', 'sources': [ @@ -17,7 +50,7 @@ ], 'dependencies': [ '<(DEPTH)/exports.gyp:nss_exports', - '<(DEPTH)/fuzz/libFuzzer/libFuzzer.gyp:libFuzzer' + '<(DEPTH)/fuzz/libFuzzer.gyp:libFuzzer' ] } ], diff --git a/fuzz/git-copy.sh b/fuzz/git-copy.sh new file mode 100755 index 000000000..1389ddabd --- /dev/null +++ b/fuzz/git-copy.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +set -e + +if [ $# -lt 3 ]; then + echo "Usage: $0 <repo> <branch> <directory>" 1>&2 + exit 2 +fi + +REPO=$1 +COMMIT=$2 +DIR=$3 + +echo "Copy '$COMMIT' from '$REPO' to '$DIR'" +if [ -f $DIR/.git-copy ]; then + CURRENT=$(cat $DIR/.git-copy) + if [ $(echo -n $COMMIT | wc -c) != "40" ]; then + ACTUAL=$(git ls-remote $REPO $COMMIT | cut -c 1-40 -) + else + ACTUAL=$COMMIT + fi + if [ CURRENT = ACTUAL ]; then + echo "Up to date." + fi +fi + +mkdir -p $DIR +git -C $DIR init -q +git -C $DIR fetch -q --depth=1 $REPO $COMMIT:git-copy-tmp +git -C $DIR reset --hard git-copy-tmp +git -C $DIR show-ref HEAD | cut -c 1-40 - > $DIR/.git-copy +rm -rf $DIR/.git diff --git a/fuzz/libFuzzer/libFuzzer.gyp b/fuzz/libFuzzer/libFuzzer.gyp deleted file mode 100644 index 08aa284fc..000000000 --- a/fuzz/libFuzzer/libFuzzer.gyp +++ /dev/null @@ -1,43 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -{ - 'includes': [ - '../../coreconf/config.gypi' - ], - 'targets': [ - { - 'target_name': 'libFuzzer', - 'type': 'static_library', - 'sources': [ - 'FuzzerCrossOver.cpp', - 'FuzzerDriver.cpp', - 'FuzzerExtFunctionsDlsym.cpp', - 'FuzzerExtFunctionsWeak.cpp', - 'FuzzerIO.cpp', - 'FuzzerLoop.cpp', - 'FuzzerMutate.cpp', - 'FuzzerSHA1.cpp', - 'FuzzerTracePC.cpp', - 'FuzzerTraceState.cpp', - 'FuzzerUtil.cpp', - 'FuzzerUtilDarwin.cpp', - 'FuzzerUtilLinux.cpp', - ], - 'cflags': [ - '-O2', - ], - 'cflags/': [ - ['exclude', '-fsanitize='], - ['exclude', '-fsanitize-'], - ], - 'xcode_settings': { - 'GCC_OPTIMIZATION_LEVEL': '2', # -O2 - 'OTHER_CFLAGS/': [ - ['exclude', '-fsanitize='], - ['exclude', '-fsanitize-'], - ], - }, - } - ], -} |