• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2018 Google Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18# build project
19cmake -DDNP3_FUZZING=ON -DSTATICLIBS=ON .
20make -j$(nproc) all
21
22cd cpp/tests/fuzz
23
24TARGETS="fuzzdecoder \
25  fuzzoutstation \
26  fuzzmaster"
27
28for target in $TARGETS; do
29  # build corpus
30  zip -r ${target}_seed_corpus.zip corpus/*.dnp
31  cp ${target}_seed_corpus.zip $OUT/
32
33  # export other associated stuff
34  cp fuzzdnp3.options $OUT/${target}.options
35
36  # build fuzz target
37  $CXX $CXXFLAGS -I. -I ../../libs/include/ -I ../../tests/libs/src/ -I ../../libs/src/ -c ${target}.cpp -o ${target}.o
38  $CXX $CXXFLAGS -std=c++14 ${target}.o -o $OUT/${target} ../../../libdnp3mocks.a ../../../libtestlib.a ../../../libasiodnp3.a ../../../libdnp3decode.a ../../../libasiopal.a ../../../libopendnp3.a ../../../libopenpal.a $LIB_FUZZING_ENGINE
39done
40