Skip to content

Commit

Permalink
Use simpler clang setup for fuzzing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pro committed Jul 19, 2017
1 parent 5f435db commit 5b2b18b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 27 deletions.
24 changes: 24 additions & 0 deletions .travis-apt-pin.preferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Package: clang-3.9
Pin: release o=Ubuntu
Pin-Priority: -1

Package: libclang-common-3.9-dev
Pin: release o=Ubuntu
Pin-Priority: -1

Package: libclang1-3.9
Pin: release o=Ubuntu
Pin-Priority: -1

Package: libllvm3.9v4
Pin: release o=Ubuntu
Pin-Priority: -1

Package: clang-tidy-3.9
Pin: release o=Ubuntu
Pin-Priority: -1

Package: libfuzzer-3.9-dev
Pin: release o=Ubuntu
Pin-Priority: -1

2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ addons:
- binutils-mingw-w64-i686
- build-essential
- check
- clang-3.9
- clang-tidy-3.9
- cmake
- cppcheck
- gcc-multilib
Expand Down
13 changes: 5 additions & 8 deletions tests/fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ if(NOT "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang")
endif()

if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
MESSAGE(WARNING "You should use at least clang version 5.0 for fuzzing support")
endif()

if(NOT $ENV{LIB_FUZZER_DIR} STREQUAL "")
# specific settings for travis
link_directories($ENV{LIB_FUZZER_DIR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-coverage=trace-pc-guard")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-coverage=trace-pc-guard")
endif()

set(LIBS Fuzzer ${open62541_LIBRARIES})
Expand All @@ -29,8 +28,6 @@ set(LIBS Fuzzer ${open62541_LIBRARIES})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/fuzz)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-coverage=trace-pc-guard")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-coverage=trace-pc-guard")


# Use different plugins for testing
Expand Down
24 changes: 12 additions & 12 deletions tools/travis/travis_linux_before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
set -ev


if ! [ -z ${FUZZER+x} ]; then
# we need libfuzzer 5.0, all the older versions do not work on travis.
sudo apt-get --yes install git
git clone https://github.com/google/fuzzer-test-suite.git FTS
./FTS/tutorial/install-deps.sh # Get deps
./FTS/tutorial/install-clang.sh # Get fresh clang binaries
# Get libFuzzer sources and build it
svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer
Fuzzer/build.sh
exit 0
fi

if [ -z ${DOCKER+x} ]; then
# Only on non-docker builds required

echo "=== Installing from external package sources ===" && echo -en 'travis_fold:start:before_install.external\\r'

if [ "$CC" = "clang" ]; then
# the ubuntu repo has a somehow broken clang-3.9 compiler. We want to use the one from the llvm repo
# See https://github.com/openssl/openssl/commit/404c76f4ee1dc51c0d200e2b60a6340aadb44e38
sudo cp .travis-apt-pin.preferences /etc/apt/preferences.d/no-ubuntu-clang
curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add -
echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" | sudo tee -a /etc/apt/sources.list > /dev/null
sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
sudo -E apt-get -yq update
sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install clang-3.9 clang-tidy-3.9 libfuzzer-3.9-dev
fi

sudo add-apt-repository -y ppa:lttng/ppa
sudo apt-get update -qq
sudo apt-get install -y liburcu4 liburcu-dev
Expand Down
8 changes: 3 additions & 5 deletions tools/travis/travis_linux_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ fi
# Fuzzer build test
if ! [ -z ${FUZZER+x} ]; then
mkdir -p build && cd build
export CC=$TRAVIS_BUILD_DIR/third_party/llvm-build/Release+Asserts/bin/clang
export CXX=$TRAVIS_BUILD_DIR/third_party/llvm-build/Release+Asserts/bin/clang++
# libFuzzer.a is in the build dir.
export LIB_FUZZER_DIR=$TRAVIS_BUILD_DIR
export CC=clang-3.9
export CXX=clang++-3.9
cmake -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_FUZZING=ON ..
make VERBOSE=1 && make run_fuzzer
make && make run_fuzzer
if [ $? -ne 0 ] ; then exit 1 ; fi
cd .. && rm build -rf
exit 0
Expand Down

0 comments on commit 5b2b18b

Please sign in to comment.