tests/test-fuzz-targets.t
author Pulkit Goyal <pulkit@yandex-team.ru>
Thu, 31 Jan 2019 20:11:16 +0300
changeset 41719 5f9d057ba28c
parent 40727 d9fc51f77cc5
child 42948 39cab871e880
permissions -rw-r--r--
changegroup: don't try to prune manifest nodes if not ellipses In non-ellipses case, the number of manifest nodes can be very big, and finding whether one of them can be pruned or not is very costly. For each node, we try to find the rev and the linkrev, which is expensive. Sending bit more manifest nodes seems better and much faster here. On our internal repository, this saves around 5 seconds on `hg tracked --addinclude <some_path>` on a narrow repo with ellipses disabled. Differential Revision: https://phab.mercurial-scm.org/D5782

#require test-repo

  $ cd $TESTDIR/../contrib/fuzz

which(1) could exit nonzero, but that's fine because we'll still end
up without a valid executable, so we don't need to check $? here.

  $ if which gmake >/dev/null 2>&1; then
  >     MAKE=gmake
  > else
  >     MAKE=make
  > fi

  $ havefuzz() {
  >     cat > $TESTTMP/dummy.cc <<EOF
  > #include <stdlib.h>
  > #include <stdint.h>
  > int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
  > int main(int argc, char **argv) {
  >     const char data[] = "asdf";
  >     return LLVMFuzzerTestOneInput((const uint8_t *)data, 4);
  > }
  > EOF
  >     $CXX $TESTTMP/dummy.cc -o $TESTTMP/dummy \
  >        -fsanitize=fuzzer-no-link,address || return 1
  > }

#if clang-libfuzzer
  $ CXX=clang++ havefuzz || exit 80
  $ $MAKE -s clean all
#endif
#if no-clang-libfuzzer clang-6.0
  $ CXX=clang++-6.0 havefuzz || exit 80
  $ $MAKE -s clean all CC=clang-6.0 CXX=clang++-6.0
#endif
#if no-clang-libfuzzer no-clang-6.0
  $ exit 80
#endif

Just run the fuzzers for five seconds each to verify it works at all.
  $ ./bdiff -max_total_time 5
  $ ./mpatch -max_total_time 5
  $ ./xdiff -max_total_time 5