1# Copyright 2017 Google Inc. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15add_subdirectory(libfuzzer) 16 17add_library(protobuf-mutator 18 binary_format.cc 19 mutator.cc 20 text_format.cc 21 utf8_fix.cc) 22target_link_libraries(protobuf-mutator 23 ${PROTOBUF_LIBRARIES}) 24set_property(TARGET protobuf-mutator 25 PROPERTY COMPILE_FLAGS "${NO_FUZZING_FLAGS}") 26 27protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS 28 mutator_test_proto2.proto 29 mutator_test_proto3.proto) 30 31add_executable(mutator_test 32 mutator_test.cc 33 utf8_fix_test.cc 34 weighted_reservoir_sampler_test.cc 35 ${PROTO_SRCS}) 36target_link_libraries(mutator_test 37 protobuf-mutator 38 ${ZLIB_LIBRARIES} 39 ${GTEST_BOTH_LIBRARIES} 40 ${CMAKE_THREAD_LIBS_INIT}) 41 42ProcessorCount(CPU_COUNT) 43math(EXPR TEST_SHARDS_COUNT 2*${CPU_COUNT}) 44math(EXPR TEST_SHARDS_MAX ${TEST_SHARDS_COUNT}-1) 45foreach(SHARD RANGE ${TEST_SHARDS_MAX}) 46 add_test(test.protobuf_mutator_test_${SHARD} mutator_test --gtest_color=yes AUTO) 47 set_property( 48 TEST test.protobuf_mutator_test_${SHARD} 49 APPEND PROPERTY ENVIRONMENT 50 GTEST_SHARD_INDEX=${SHARD} 51 GTEST_TOTAL_SHARDS=${TEST_SHARDS_COUNT}) 52endforeach(SHARD) 53 54add_dependencies(check mutator_test) 55