From 1a6f3d39a7739e4c3d4fd79beb7adff2b94b23ff Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 11 Feb 2024 12:17:09 +0100 Subject: [PATCH] build: remove symbolic links from repository This will reduce cross-platform differences between windows and linux. Closes https://github.com/tree-sitter/tree-sitter/issues/627. --- CONTRIBUTING.md | 2 +- script/reproduce | 31 ++++++++++++++++++++- script/run-fuzzer | 68 +++++++++++++++-------------------------------- 3 files changed, 52 insertions(+), 49 deletions(-) mode change 120000 => 100644 CONTRIBUTING.md mode change 120000 => 100755 script/reproduce diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 120000 index 4f643710..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -docs/section-6-contributing.md \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..42bc7b75 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +See [section-6-contributing.md](./docs/section-6-contributing.md) diff --git a/script/reproduce b/script/reproduce deleted file mode 120000 index 1c28442a..00000000 --- a/script/reproduce +++ /dev/null @@ -1 +0,0 @@ -run-fuzzer \ No newline at end of file diff --git a/script/reproduce b/script/reproduce new file mode 100755 index 00000000..80b01af5 --- /dev/null +++ b/script/reproduce @@ -0,0 +1,30 @@ +#!/bin/bash + +set -eux + +root=$(dirname "$0")/.. +export ASAN_OPTIONS="quarantine_size_mb=10:detect_leaks=1:symbolize=1" +export UBSAN="print_stacktrace=1:halt_on_error=1:symbolize=1" + +# check if CI env var exists + +if [ -z "${CI:-}" ]; then + declare -A mode_config=( ["halt"]="-timeout=1 -rss_limit_mb=2048" ["recover"]="-timeout=10 -rss_limit_mb=2048" ) +else + declare -A mode_config=( ["halt"]="-max_total_time=120 -timeout=1 -rss_limit_mb=2048" ["recover"]="-time=120 -timeout=10 -rss_limit_mb=2048" ) +fi + +if [ "$#" -lt 3 ]; then + echo "usage: $0 (halt|recover) " + exit 1 +fi + +lang="$1" +shift +mode="$1" +shift +testcase="$1" +shift +# Treat remainder of arguments as libFuzzer arguments + +"${root}/test/fuzz/out/${lang}_fuzzer" "${mode_config[$mode]}" -runs=1 "${testcase}" "$@" diff --git a/script/run-fuzzer b/script/run-fuzzer index ae73958b..d1e96315 100755 --- a/script/run-fuzzer +++ b/script/run-fuzzer @@ -14,51 +14,25 @@ else declare -A mode_config=( ["halt"]="-max_total_time=120 -timeout=1 -rss_limit_mb=2048" ["recover"]="-time=120 -timeout=10 -rss_limit_mb=2048" ) fi -run_fuzzer() { - if [ "$#" -lt 2 ]; then - echo "usage: $0 " - exit 1 - fi - - lang="$1" - shift - mode="$1" - shift - # Treat remainder of arguments as libFuzzer arguments - - # Fuzzing logs and testcases are always written to `pwd`, so `cd` there first - results="${root}/test/fuzz/out/fuzz-results/${lang}" - mkdir -p "${results}" - cd "${results}" - - # Create a corpus directory, so new discoveries are stored on disk. These will - # then be loaded on subsequent fuzzing runs - mkdir -p corpus - - pwd - "../../${lang}_fuzzer" "-dict=../../${lang}.dict" "-artifact_prefix=${lang}_" -max_len=2048 "${mode_config[$mode]}" "./corpus" "$@" -} - -reproduce() { - if [ "$#" -lt 3 ]; then - echo "usage: $0 (halt|recover) " - exit 1 - fi - - lang="$1" - shift - mode="$1" - shift - testcase="$1" - shift - # Treat remainder of arguments as libFuzzer arguments - - "${root}/test/fuzz/out/${lang}_fuzzer" "${mode_config[$mode]}" -runs=1 "${testcase}" "$@" -} - -script=$(basename "$0") -if [ "$script" == "run-fuzzer" ]; then - run_fuzzer "$@" -elif [ "$script" == "reproduce" ]; then - reproduce "$@" +if [ "$#" -lt 2 ]; then + echo "usage: $0 " + exit 1 fi + +lang="$1" +shift +mode="$1" +shift +# Treat remainder of arguments as libFuzzer arguments + +# Fuzzing logs and testcases are always written to `pwd`, so `cd` there first +results="${root}/test/fuzz/out/fuzz-results/${lang}" +mkdir -p "${results}" +cd "${results}" + +# Create a corpus directory, so new discoveries are stored on disk. These will +# then be loaded on subsequent fuzzing runs +mkdir -p corpus + +pwd +"../../${lang}_fuzzer" "-dict=../../${lang}.dict" "-artifact_prefix=${lang}_" -max_len=2048 "${mode_config[$mode]}" "./corpus" "$@"