Repository navigation
Commit fuzzer source code. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
ef33bdd
78bc635
9de52c0
aacdef3
a91b38c
d00c6a5
d8881d6
84395e5
03fee10
5750949
888a08b
01c5daf
1f43abf
24b361a
f4c7bd7
dd72220
b9bc503
0f48672
07fca5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,3 +105,6 @@ tests/scripts/*.log | |
| tests/scripts/*.trs | ||
| tests/test-suite.log | ||
| Testing/ | ||
|
|
||
| # Vincent | ||
| build/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see this file being used anywhere. Does it really belong in the source tree? If it does belong, could it go into the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily needed, but I thought it might be helpful if someone does not want to figure out the build options by themselves. Should it go into the scripts sub-directory or be completely removed? |
||
| set -e | ||
| rm -rf build | ||
| mkdir build | ||
| cd build | ||
| CC=clang CXX=clang++ CXXFLAGS="-std=c++14" cmake .. -DXERCES_BUILD_FUZZERS=1 -Wfatal-errors | ||
| CC=clang CXX=clang++ CXXFLAGS="-std=c++14" make -j8 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # CMake build for xerces-c | ||
| # | ||
| # Written by Roger Leigh <rleigh@codelibre.net> | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Definitions required for building | ||
| add_definitions( | ||
| -DHAVE_CONFIG_H=1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is necessary, I think target_compile_definitions would be more appropriate, rather than setting it globally. |
||
| ) | ||
| # Search the project binary dir for config.h | ||
| include_directories( | ||
| ${PROJECT_BINARY_DIR} | ||
| ${PROJECT_SOURCE_DIR}/src | ||
| ${PROJECT_BINARY_DIR}/src | ||
| ${CMAKE_CURRENT_SOURCE_DIR} | ||
| ) | ||
| set(EXTRA_DIST | ||
| src/DOM/Normalizer/expectedOutput | ||
| src/DOM/TypeInfo/data/combined.dtd | ||
| src/DOM/TypeInfo/data/combined.xml | ||
| src/DOM/TypeInfo/data/combined.xsd | ||
| src/DOM/TypeInfo/data/SecondSchema.xsd | ||
| src/DOM/TypeInfo/data/TypeInfo.dtd | ||
| src/DOM/TypeInfo/data/TypeInfo.xml | ||
| src/DOM/TypeInfo/data/TypeInfo.xsd | ||
| src/DOM/TypeInfo/data/TypeInfoJustDTD.xml | ||
| src/DOM/TypeInfo/data/TypeInfoNoDTD.xml | ||
| src/DOM/TypeInfo/data/TypeInfoNoDTD.xsd | ||
| src/XSTSHarness/regression | ||
| src/xinclude | ||
| ) | ||
|
|
||
| macro(add_fuzzer_executable name) | ||
| add_executable(${name} ${ARGN}) | ||
| target_link_libraries(${name} xerces-c) | ||
| target_compile_options(${name} PUBLIC -fsanitize=fuzzer) | ||
| target_link_libraries(${name} -fsanitize=fuzzer) | ||
| set_target_properties(${name} PROPERTIES FOLDER "Fuzzers") | ||
| endmacro() | ||
|
|
||
| add_fuzzer_executable(fuzz_parser_target | ||
| src/xerces_fuzz_common.cpp | ||
| src/parse_target.cpp | ||
|
|
||
| ) | ||
|
|
||
| include(ExternalProject) | ||
|
|
||
| set(EXTERNAL_INSTALL_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/external) | ||
|
|
||
|
|
||
| ExternalProject_Add(libprotobuf-mutator | ||
| GIT_SHALLOW 1 | ||
| GIT_REPOSITORY https://github.com/google/libprotobuf-mutator.git | ||
| CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON -DLIB_PROTO_MUTATOR_TESTING=false -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} | ||
| ) | ||
|
|
||
| set(PROTOC_PATH /usr/local/bin/protoc) #${CMAKE_CURRENT_BINARY_DIR}/libprotobuf-mutator-prefix/src/libprotobuf-mutator-build/external.protobuf/bin/protoc) | ||
| #set(PROTOC_PATH ${CMAKE_CURRENT_BINARY_DIR}/libprotobuf-mutator-prefix/src/libprotobuf-mutator-build/external.protobuf/bin/protoc) | ||
|
|
||
| message(STATUS "### Vincent Debug: ${CMAKE_CURRENT_SOURCE_DIR} ${PROTOC_PATH} ${EXTERNAL_INSTALL_LOCATION} ${CMAKE_CURRENT_BINARY_DIR}/libprotobuf-mutator-prefix/src/libprotobuf-mutator-build/external.protobuf/src/external.protobuf-build/libprotobuf.a") | ||
|
|
||
| add_custom_command( | ||
| OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/genfiles ${CMAKE_CURRENT_BINARY_DIR}/genfiles/xml.pb.cc | ||
| DEPENDS libprotobuf-mutator | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
| COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/genfiles && ${PROTOC_PATH} xml.proto --cpp_out=${CMAKE_CURRENT_BINARY_DIR}/genfiles | ||
| ) | ||
| add_custom_target(xml_proto_files ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/genfiles) | ||
|
|
||
|
|
||
|
|
||
| add_fuzzer_executable(fuzz_parser_target_proto | ||
| src/xerces_fuzz_common.cpp | ||
| src/parse_target_proto.cpp | ||
| src/xmlProtoConverter.cpp | ||
| ${CMAKE_CURRENT_BINARY_DIR}/genfiles/xml.pb.cc | ||
| ) | ||
| add_dependencies(fuzz_parser_target_proto xml_proto_files) | ||
| add_dependencies(fuzz_parser_target_proto libprotobuf-mutator) | ||
| target_include_directories(fuzz_parser_target_proto PUBLIC ${EXTERNAL_INSTALL_LOCATION}/include) | ||
| target_include_directories(fuzz_parser_target_proto PUBLIC ${EXTERNAL_INSTALL_LOCATION}/include/libprotobuf-mutator/) | ||
| target_include_directories(fuzz_parser_target_proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/genfiles) | ||
| target_link_libraries(fuzz_parser_target_proto ${EXTERNAL_INSTALL_LOCATION}/lib/libprotobuf-mutator-libfuzzer.a) | ||
| target_link_libraries(fuzz_parser_target_proto ${EXTERNAL_INSTALL_LOCATION}/lib/libprotobuf-mutator.a) | ||
| target_link_libraries(fuzz_parser_target_proto ${CMAKE_CURRENT_BINARY_DIR}/libprotobuf-mutator-prefix/src/libprotobuf-mutator-build/external.protobuf/src/external.protobuf-build/libprotobuf.a) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should be kept private. Please could you remove it from the PR?