Patchwork D9752: fuzz: try and ensure fuzzer tests run against the right python-config

login
register
mail settings
Submitter phabricator
Date Jan. 13, 2021, 8:44 p.m.
Message ID <differential-rev-PHID-DREV-32c2vqdoty2k3z5jigwg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48063/
State Superseded
Headers show

Comments

phabricator - Jan. 13, 2021, 8:44 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Also only under python 3.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9752

AFFECTED FILES
  contrib/fuzz/Makefile
  tests/test-fuzz-targets.t

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-fuzz-targets.t b/tests/test-fuzz-targets.t
--- a/tests/test-fuzz-targets.t
+++ b/tests/test-fuzz-targets.t
@@ -1,4 +1,4 @@ 
-#require test-repo
+#require test-repo py3
 
   $ cd $TESTDIR/../contrib/fuzz
   $ OUT=$TESTTMP ; export OUT
@@ -26,13 +26,23 @@ 
   >        -fsanitize=fuzzer-no-link,address || return 1
   > }
 
+Try to find a python3-config that's next to our sys.executable. If
+that doesn't work, fall back to looking for a global python3-config
+and hope that works out for the best.
+  $ PYBIN=`$PYTHON -c 'import sys, os; print(os.path.dirname(sys.executable))'`
+  $ if [ -x "$PYBIN/python3-config" ] ; then
+  >   PYTHON_CONFIG="$PYBIN/python3-config"
+  > else
+  >   PYTHON_CONFIG="`which python3-config`"
+  > fi
+
 #if clang-libfuzzer
   $ CXX=clang++ havefuzz || exit 80
-  $ $MAKE -s clean all PYTHON_CONFIG=`which python-config`
+  $ $MAKE -s clean all PYTHON_CONFIG="$PYTHON_CONFIG"
 #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 PYTHON_CONFIG=`which python-config`
+  $ $MAKE -s clean all CC=clang-6.0 CXX=clang++-6.0 PYTHON_CONFIG="$PYTHON_CONFIG"
 #endif
 #if no-clang-libfuzzer no-clang-6.0
   $ exit 80
diff --git a/contrib/fuzz/Makefile b/contrib/fuzz/Makefile
--- a/contrib/fuzz/Makefile
+++ b/contrib/fuzz/Makefile
@@ -23,6 +23,7 @@ 
 	python $< $@
 
 pyutil.o: pyutil.cc pyutil.h
+	$(PYTHON_CONFIG) --cflags
 	$(CXX) $(CXXFLAGS) -g -O1 \
 	  `$(PYTHON_CONFIG) --cflags` \
 	  -I../../mercurial -c -o pyutil.o pyutil.cc