diff --git a/.circleci/config.yml b/.circleci/config.yml index 1cf4bc885..b81564d2a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -90,6 +90,18 @@ jobs: - run: make -j32 - run: LD_LIBRARY_PATH="$PWD/freetype-2.9/objs/.libs" make check || .ci/fail.sh + gcc-valgrind: + docker: + - image: ubuntu:18.10 + steps: + - checkout + - run: apt update || true + - run: apt install -y gcc binutils libtool autoconf automake make pkg-config gtk-doc-tools ragel libfreetype6-dev libfontconfig1-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip valgrind + - run: pip install fonttools + - run: ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2 --with-fontconfig + - run: make -j32 + - run: make check || .ci/fail.sh + clang-everything: docker: - image: ubuntu:18.10 @@ -293,6 +305,7 @@ workflows: # autotools based builds - alpine-O3-NOMMAP - archlinux-debug-O0-py3 + - gcc-valgrind - clang-O3-O0 - clang-everything - clang-asan diff --git a/test/fuzzing/run-shape-fuzzer-tests.py b/test/fuzzing/run-shape-fuzzer-tests.py index 8fadd167f..dcdab6715 100755 --- a/test/fuzzing/run-shape-fuzzer-tests.py +++ b/test/fuzzing/run-shape-fuzzer-tests.py @@ -5,6 +5,24 @@ from __future__ import print_function, division, absolute_import import sys, os, subprocess, tempfile, threading +def which(program): + # https://stackoverflow.com/a/377028 + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, _ = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None + + def cmd(command): # https://stackoverflow.com/a/4408409 # https://stackoverflow.com/a/10012262 @@ -49,6 +67,8 @@ please provide it as the first argument to the tool""") print ('hb_shape_fuzzer:', hb_shape_fuzzer) fails = 0 +valgrind = which ('valgrind') + parent_path = os.path.join (srcdir, "fonts") for file in os.listdir (parent_path): path = os.path.join(parent_path, file) @@ -56,8 +76,19 @@ for file in os.listdir (parent_path): text, returncode = cmd ([hb_shape_fuzzer, path]) print (text) + failed = False if returncode != 0 or 'error' in text: print ('failure on %s' % file) + failed = True + + if valgrind: + text, returncode = cmd ([valgrind, '--error-exitcode=1', hb_shape_fuzzer, path]) + if returncode: + print (text) + print ('failure on %s' % file) + failed = True + + if failed: fails = fails + 1 if fails: